我正在构建一个带有Django Rest Framework API后端的单页Web应用程序。我有问题发送注册表单。我认为格式化日期的方式存在问题。 这里的控制器的样子:在http发布请求期间angularjs 400错误请求
(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 : 星期五1993年8月6日00:00:00 GMT-0400(东部夏令时间) 名字 : “David” 性别 : “M” 姓氏 : “加洛韦” 用户 : 对象 电子邮件 : “[email protected]” 密码 : “*******” 原 : 对象 原 : 对象
试了一下,它仍在发送回400错误的请求 –