Server Code:
const express = require('express')
const app = express() app.use(express.static('public')) app.use(express.json({limit :'100mb'}));
app.post('/post', (req, res) => { console.log('post called');
console.log(req.body); ////Printed here
})
app.listen(3000)
Client code:
const data ={agent: 41} const options = { method: 'POST', mode: 'no-cors', credentials: 'same-origin', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) };
fetch('http://localhost:3000/post', options);
output in server terminal
can anyone please tell me what am i doing wrong, how can i get the value?
Expected Output : {agent: 41}