[英]How to handle fetch errors?
我知道有很多關於fetch erros的問題,但似乎沒有人對我有任何幫助。 每個站點或文檔都說fetch不會引發錯誤,但這似乎不正確。 例如,404錯誤會在控制台上拋出,但隨后會調用then而不是catch。 那么,問題是,如何避免圖像上的錯誤噪音?
then
我在Edge瀏覽器上測試了相同的假提取調用,同樣的情況發生了,然后調用了部分,但是錯誤被記錄到控制台中。 我怎么能避免呢?
使用catch 。
catch
fetch('/fake').then(console.log).catch(() => doSomethingFun());
[英]How do I handle JavaScript Fetch errors?
[英]How to handle errors in fetch() responses with Redux Thunk?
[英]Async/Await in fetch() how to handle errors
[英]Handle errors in a reusable fetch function
[英]Two Views, One Model - How to handle fetch errors for both?
[英]How do I handle reactive async fetch input field errors?
[英]How to handle errors in fetch() responses with Redux-Saga?
[英]How handle errors with JS fetch again Laravel Api
[英]How to handle errors in AngularJS
[英]How to handle errors in Ramda
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.