The issue
GET /api/get-requestworks correctly, and `{ x: 'x' } is returned to the frontendPOST /api/post-requestworks too but returns empty body
How I run json-server:
json-server src/configs/api/mocks/json-server-generator.js --routes src/configs/api/mocks/json-server-routes.json --watch"
json-server-routes.json
{
"/api/getrequest": "/getrequest",
"/api/postrequest": "/postrequest",
}
json-server-generator.js
module.exports = () => {
return {
getrequest: { x: 'x' },
postrequest: { y: 'y' }
}
}
Requests are made via fetch:
fetch(url, {
method,
headers: {
'content-type': 'application/json'
},
body: JSON.stringify(payload)
})