You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The json middleware does not parse results as json if the content type is anything but application/json, I would expect it to also work on content types like application/ld+json. For instance:
importexpressfrom'express';constapp=express();app.use(express.json());app.post('/',async(req,res)=>{console.log("Data posted",awaitreq.body);});app.listen(3000,()=>{console.log('Listening on port 3000');fetch('http://localhost:3000',{method: 'POST',headers: {'Content-Type': 'application/json',},body: JSON.stringify({message: 'Hello world',}),});});
returns
Listening on port 3000
Data posted { message: 'Hello world' }
On the other hand
importexpressfrom'express';constapp=express();app.use(express.json());app.post('/',async(req,res)=>{console.log("Data posted",awaitreq.body);});app.listen(3000,()=>{console.log('Listening on port 3000');fetch('http://localhost:3000',{method: 'POST',headers: {'Content-Type': 'application/ld+json',},body: JSON.stringify({message: 'Hello world',}),});});
The json middleware does not parse results as json if the content type is anything but
application/json, I would expect it to also work on content types likeapplication/ld+json. For instance:returns
On the other hand
returns