Reputation: 91
This is my code on the front end
fetch('http://localhost:5001/api/data', {
method: 'PATCH',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"formulaString": formula,
"index": props.id
})
And just to test things; my backend code is kept simple as follows
app.patch('/api/data', (req, res) => { console.log(req.body) }
On triggering the event that leads to the request on the front end; My network has two items :
My backend just logs Undefined
which I assume is from the preflight. Not sure on how I should be tackling this; Any help would be much appreciated.
Upvotes: 0
Views: 1000
Reputation: 1440
Your server not sending any response.
app.patch('/api/data', (req, res) => { console.log(req.body); }
Instead
app.patch('/api/data', (req, res) => {
console.log(req.body);
res.send("working fine")
}
Upvotes: 1