Answer the question
In order to leave comments, you need to log in
DELETE request to the backend, how to correctly fill in the headers field in fetch?
there is a method in the backend that waits for req.getHeader("teacherId")
from the front
how to correctly fill in the headers field in fetch?
with insomnia the request happens
Tried like this:
fetch('http://localhost:8080/teachers', {
method: 'DELETE',
headers: {
"teacherId": 8
}
})
Answer the question
In order to leave comments, you need to log in
The heading is put, only there the Teacherid becomes
const fetch = require('node-fetch');
fetch('https://httpbin.org/delete', {
method: 'DELETE',
headers: {
"teacherId": 8
}
})
.then(res => res.text())
.then(text => {
console.log(text);
});
/usr/local/bin/node /Users/evgenij/projects/fetch.js
{
"args": {},
"data": "",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip,deflate",
"Host": "httpbin.org",
"Teacherid": "8",
"User-Agent": "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)",
"X-Amzn-Trace-Id": "Root=1-5e99af90-fe7e43f7f3d1149a814fd762"
},
"json": null,
"origin": "*******",
"url": "https://httpbin.org/delete"
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question