Javascript fetch只抛出TypeError吗
我可以假设fetch只能抛出类型错误的错误吗Javascript fetch只抛出TypeError吗,javascript,reactjs,fetch,Javascript,Reactjs,Fetch,我可以假设fetch只能抛出类型错误的错误吗 const request = async () => { let response = null; try { response = await fetch('https://api.com/values/1'); } catch (err){ //is the err here is always of type typeError } if(!response.ok){
const request = async () => {
let response = null;
try {
response = await fetch('https://api.com/values/1');
} catch (err){
//is the err here is always of type typeError
}
if(!response.ok){
//bla bla bla 401/403 ...
}
const json = await response.json();
console.log(json);
}
request();
fetch
也可以抛出abortorror
。有关更多详细信息,请参阅