Answer the question
In order to leave comments, you need to log in
Accept json on client from nodejs/express server?
Good afternoon! Please tell me how can I send data from the nodejs / express server and receive it in json format on the client?
There should be something like this on the server
app.get ('/', function (req, res) {
// res.setHeader ( 'Content-Type "," application / json');
res.json ({message: `API Initialized!`});
});
Answer the question
In order to leave comments, you need to log in
fetch('/')
.then(response => response.json())
.then(console.log);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question