0

I'm using the js fetch() function to access to my api but I get the error

POST mywebsite net::ERR_HTTP2_PROTOCOL_ERROR

My api work perfectly with my android app, and this error appear when I add a bearer token to the header

call(url, formBody, callback) {
    const requestOptions = {
        method: 'POST',
        headers: this.getHeader(),
        body: formBody,
        redirect: 'follow'
    };
    fetch(url, requestOptions)
        .then(response => response.text())
        .then(result => {
            callback(result)
        })
        .catch(error => {
            console.log('error', error)
                });
}getHeader() {
    const myHeaders = new Headers();
    myHeaders.append("Authorization", "Bearer   " + this.getValidToken())
    return myHeaders;
}

I have tried with xmlhttprequest It's the same error

Tom Jumel
  • 41
  • 4
  • Does [this](https://stackoverflow.com/questions/58215104/whats-the-neterr-http2-protocol-error-about) help you? – Tushar Jul 07 '20 at 08:34
  • Does this answer your question? [What's the net::ERR\_HTTP2\_PROTOCOL\_ERROR about?](https://stackoverflow.com/questions/58215104/whats-the-neterr-http2-protocol-error-about) – Yash.S.Narang Jul 07 '20 at 08:37
  • Not really because I don't understand how to solve it... – Tom Jumel Jul 07 '20 at 08:47

0 Answers0