Catching "failed To Load Resource" When Using The Fetch Api
I'm trying to catch a bunch of errors related to the same origin policy when using the Fetch API but without any success: window.onerror = (message, file, line, col, error) => c
Solution 1:
As far as I remember, you can not catch
browser driven exceptions in your typical try->catch
or a catch chain
inside of fetch
.
CORS exceptions are thrown with intent, to have the user browsing the site, know of such abnormalities if you may call them that, and to protect any leak of possible secure information on the called api/server
Read here Of a previous SO discussion on whether you could catch these errors with an exception handler
If the request throws an error that can be part of the response , like a status error and such, then you may catch it and show a custom message
Post a Comment for "Catching "failed To Load Resource" When Using The Fetch Api"