1

I am trying to make a POST request from Edge browser in my React project. I sent request to server but i didn't get success response i am getting Failed to Fetch message

  {
   description: "Failed to Fetch",
   message: "Failed to Fetch",
   number: 1223243243
  }

Here is my fetch client code

 processRequest(url, method, body, headers, fetchOpts) {
    return new Promise((resolve, reject) => {
        const requestHeaders = new Headers(headers);
        const init = { method, mode: 'cors' };
        if (body) {
            init.body = body;
        }
        if (headers) {
            init.headers = new Headers(headers);
        }
        if (fetchOpts) {
            Object.assign(init, fetchOpts);
        }
        if (!['GET', 'POST', 'PUT', 'DELETE'].some(v => method === v)) {
            reject(new Error(`FetchClient::processRequest: Unsupported method: ${method}`));
        }
        else {
            const start = Date.now();
            Log.debug(`Fetch request: ${method} ${url} [body]:${body ? body : 'none'}`);
            fetch(url, init)
                .then(response => {
                this._lastActivity = new Date();
                Log.debug(`perf::Fetch request took: ${Date.now() - start} ms`);
                resolve(response);
            })
                .catch(error => {
                this._lastActivity = new Date();
                reject(error);
            });
        }
    });
}

Can you please tell me the root cause for this error.

Thanks in advance

Manikanta
  • 325
  • 6
  • 20
  • post your fetch call? – joy08 Mar 17 '20 at 12:14
  • Please check the fetch call – Manikanta Mar 18 '20 at 03:26
  • Which version of Microsoft Edge are you using? Whether this error only occurs in Microsoft Edge browser? Try to test your code on the Chrome browser, and check whether it works well? Besides, please check the request and response header, whether they are matched or not? here are some thread with the similar error, you could check them: [Link 1](https://stackoverflow.com/questions/49343024/) and [Link 2](https://stackoverflow.com/questions/42754388/). – Zhi Lv Mar 18 '20 at 09:45
  • 1
    Error occurs only in Microsoft Edge browser only, I am using version 44. fetch call works fine in other browsers. there is no difference between request and headers. but we are not getting response – Manikanta Mar 18 '20 at 12:57
  • Can you check whether the sever side could receive the request and send the response? – Zhi Lv Mar 19 '20 at 09:33
  • server side they are receiving request and they are sending response from their end. but i can't get the data in success function – Manikanta Mar 19 '20 at 11:01
  • Yes they can debug the request and they are returning the response – Manikanta Mar 20 '20 at 06:34

0 Answers0