Documentation from Express response.send allows for objects to be sent in the body, which I am sending as follows:
DBM.saveArticle(obj).then((val) => {
console.log(val); // verified here
res.send(val);
res.end();
// ... clip here
However on the client I am not getting the object. This is a Create in CRUD, and I am using fetch POST as follows to implement this.
// ... snip
const options = {
headers: {'Content-Type': 'application/json'},
method: 'POST',
body: JSON.stringify(this.state)
};
fetch("/articles/add", options)
.then((response) => {
console.log('DEBUG: Article Added: ', response); // nothing found here in response
this.props.dispatch({type: 'addArticle', component_state: state});
})
.catch((error) => {
console.log('fetch/POST error', error);
});
// ... snip
console.log from above looks like this, here is a pic, it is empty, as far as I can tell.
The response object is big, and I tried to click all about it, but it is possible I might have missed something.
The official docs for JavaScript fetch response object is here on MDN.
