fetch not sending body code example
Example 1: sending json data uing fetch is empty
var myHeaders = new Headers();
myHeaders.append('Content-Type', 'application/json');
fetch('/contact-form', {
method: 'POST',
headers: myHeaders,
mode: 'cors',
cache: 'default',
body: JSON.stringify(fields)
}).then(() => {
dispatch(contactFormSubmitSuccess());
});
Example 2: sending json data uing fetch is empty
fetch('/api/v1/users', {
method: 'post',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ "user": {
"email" : email,
"password" : password
}}),
})