Skip to main content

JSON POST headers

  • August 17, 2022
  • 1 reply
  • 22 views

In a fetch for JSON POST adding these two headers:

let response = await fetch(url, {
    method: 'POST',
    body: JSON.stringify(data),
    headers:
    {
        'Content-Type': 'application/json',
        'Accept': 'text/plain', 
    }
});

returns a TypeError: Load failed message. But the target API needs both headers specified. Each header individually does not error, but the API doesn’t respond.

Any help appreciated.

This topic has been closed for replies.

1 reply

  • Author
  • New Participant
  • August 24, 2022

Solved by using remoteFetchAsync instead of fetch.