Vote count:
0
I am trying to get an Express REST API working, and for some reason the JSON body always ends up with unnecessary quotation marks. I am using the following configuration in the Express middleware:
app.use(bodyParse.urlencoded({
extended: true
}));
app.use(bodyParser.json());
And am using
console.log(JSON.stringify(req.body));
To test this. With request body
{"name": "New Event", "description": "Hello. This is event"}
I get
{"{\"name\": \"New Event Thingy\", \"description\": \"Hello. This is event\"}":""}
and with body
"name": "New Event", "description": "Hello. This is event"
I get
{"\"name\": \"New Event Thingy\", \"description\": \"Hello. This is event\"":""}
Why am I getting these unneccessary characters?
asked 32 secs ago
Express req.body is in quotes
Aucun commentaire:
Enregistrer un commentaire