Reputation: 41
This is a function that gets executed after submitting a form which then submits data to an api, all of this is being done in angular 1.5 using the $http service
I have used postman to test this methods(GET,DELETE,POST) and others and they all work fine. In my app though POST for some reason seems note to work even though in postman i follow the same structure.
the error i get is that name is a requirement which i belie is the API ensuring information is entered.
I just cant seem to understand why this works fine in post man but not within my angular application. any help would be greatly appreciated.
function createDocument(newMovie){
var req = {
method: 'POST',
url:{{some url}},
headers:
{
"Authorization": Authorization,
"content-type": "application/json"
},
body: {
"name": newMovie.name,
"description": newMovie.description,
"imgs":[
{
"url": newMovie.imgs
}
]
}
}
$http(req)
.success(function(response){
console.log('success', response);
})
.error(function(response){
console.log('error', response);
})
;
}
Upvotes: 0
Views: 27
Reputation: 1045
It should be data, not body.
data: {
"name": newMovie.name,
"description": newMovie.description,
"imgs":[
{
"url": newMovie.imgs
}
]
}
Upvotes: 1