I have this array that I am trying to use PUT to change the value of statuses
. I am using Postman (A REST client -- http://www.getpostman.com/). When I change over to the x-www-form-urlencoded
tab and put the value of statuses
to hello
it updates accordingly. Below would be the result.
[
{
__v: 0
_id: "XYXYXYXYXYXYXYXYXYXYXYXY"
tagline: "Example tagline"
title: "Example title"
statuses: ["hello"]
}
]
But when it gets more complex than a string in the array, I change the tab over to raw
and try and do a JSON PUT request there by typing {"statuses":[{"userId": true}]}
.
When doing a GET request, the following is the result.
[
{
__v: 0
_id: "XYXYXYXYXYXYXYXYXYXYXYXY"
tagline: "Example tagline"
title: "Example title"
statuses:null
}
]
How come my JSON PUT request returns null
? How can I change that?
We need to see your Node.js code to best answer you, but my guess is (I suppose you're using body-parser) you need to set the extended
option to true
so that it's able to parse more complex bodies.
So that would be :
app.use(bodyParser.urlencoded({ extended: true}));