Answer the question
In order to leave comments, you need to log in
Why isn't a custom header set in axios?
I'm trying to put a custom header in axios according to the instructions, but nothing is set
sendData () {
axios.post('http://localhost:7777', {
headers: {
'X-Custom-Header': 'foobar'
}
})
.then((res) => {
Cookies.set('Answer', res.data.answer)
})
}
'X-Custom-Header': 'foobar'
it doesn't go into the query. Why? How to put your title? This is on the serverapp.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', 'http://localhost:8080')
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE')
res.header("Access-Control-Allow-Headers", "X-Requested-With, Content-Type")
next()
})
app.post('/', (req, res) => {
console.log(req.headers)
res.send({
answer: 'Random shit recieved successfully'
})
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question