I am hitting the API by using payload and in headers giving Content-Type : 'application/json'
still in browser in request headers I’m seeing Content-Type : 'text/plain'
Because of that in the backend I am getting payload in Content-Type : 'text/plain'
export const abctrigger = (payload , signal) => {
Return fetch (API_URL, {
method: post,
Signal: signal
Body: JSON.stringify(payload),
headers: {
Content-Type : 'application/json'
}
})
.then((response) => response.text())
.then((response) => {
return respon se;
})
}
I want to Change request headers to to Content-Type : 'application/json'
2
Answers
The hyphen ‘-‘ in the property name probably causes the issue.
Try this:
Instead of this:
And check your IDE settings, because with ms-code the later gives an error:
try this:
I made 3 changes, exluding the post, that may be a variable, you forgot a comma and to round Content-Type with ”.