Я занимаюсь разработкой одностраничного веб-приложения с использованием бэкэнд API-интерфейса Django Rest Framework. У меня возникла проблема отправки регистрационных форм. Я думаю, что существует проблема с форматированием дат. Вот что контроллер выглядит следующим образом:angularjs 400 плохой запрос во время HTTP-запроса почты
(function() {
'use strict';
angular
.module('CityWits')
.controller('standardController', standardController);
standardController.$inject = ['UserService','$location', '$rootScope', 'FlashService'];
function standardController(UserService, $location, $rootScope, FlashService) {
var vm = this;
vm.standard = standard;
function standard() {
vm.dataLoading = true;
var str = [];
for(var p in vm.user){
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(vm.user[p]));
}
str = str.join("&");
UserService.CreateStandard(vm.user)
.then(function (response) {
if (response.success) {
FlashService.Success('Registration successful', true);
$location.path('/sign-in');
} else {
alert(response.message)
vm.dataLoading = false;
}
});
}
function fixDate(date){
}
}
})();
Почта запросы:
function CreateStandard(user) {
console.log(user)
return $http.post('http://127.0.0.1:8000/api/users/standard', user).then(handleSuccess, handleError('Error creating user'));
}
объект JSON, посылаемые из формы:
Object
date_of_birth : Пта 6 августа 1993 00:00:00 GMT-0400 (по восточному поясному Время) first_name : "David" Пол : "M" last_name : "Galloway" пользователь : Объект электронной : "[email protected]" пароль : "*******" прото : Объект прото : объект
Пробовали, его до сих пор отправка обратно 400 плохой запрос –