How to distinguish beetwen error CORS and disconnect network by axios

Viewed 29

I have a issue When I call api, i will 2 case

  1. network has a proplem
  2. api has CORS

and I check by code

 instance.interceptors.response.use(
    (response) => response,
    (error) => {
       if (error.message === "Network Error")
       window?.errorNetwork?.postMessage("errorNetwork");
     }
    );

but, when api if one of these two errors is encountered, it will return the same message as errorNetwork.

Now is there any way to be able to tell the difference between these 2 errors?

Thanks all.

0 Answers
Related