J
J
jeruthadam2017-09-04 18:13:57
Node.js
jeruthadam, 2017-09-04 18:13:57

Why is res.header not being set?

Can't display res.header('Content-type', 'application/json')
Tried

app.use((req, res, next) => {
  res.header('Content-type', 'application/json')
  next()
})

and
app.get('/pets', (req, res) => {
    res.header('Content-type', 'application/json')
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
gleendo, 2017-09-04
@jeruthadam

res.set("Content-Type", "application/json");

// response.json(); // Можно и так отправить json без явного указания типа

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question