Can I somehow force data: to keep the input as pure json
bdart opened this issue · 4 comments
bdart commented
Hi is there a way to force the body to stay as a json object? It looks quite strange with this:
var id = JSON.stringify(id)
console.log(id);
request({
url: TREATMENT_URL,
method: 'POST',
crossOrigin: true,
type: 'json',
contentType: 'application/json',
data: {
id: 1
}
When I make the POST call the http call does not contain {"id":1}
rather it contains this:
Request Payload:
id=%7B%22id%22%3A1%7D
How can I work around to keep it as json :(?
buob commented
I got around this by passing the flag processData: false
, and processing it myself, i.e. data: JSON.stringify({ id: 1 })
.
Duan112358 commented
not working @buob
rayzang8 commented
I meet the same issue.
If I set processData: true, it will send request body [object,object] ?
How can I send the json object like the post in angular $http.post ?