score:1

Accepted answer

in your server, send as object:

res.send({ success: true });

and

res.send({ success: false });

in your frontend, get as:

fetch('/api/messages', {
  method: 'post',
  headers: {
    'content-type': 'application/json'
  },
  body: json.stringify({ message: this.state.message })
})
.then(res => res.json())

Related Query

More Query from same tag