取消异常传播
Cancel exception propogation
当这个请求导致错误时,then 方法在 catch 方法运行之后。出现错误时如何停止运行代码?
return fetch('url here', {
credentials: "same-origin"
})
.then(res => {
return res.json();
})
.catch(err => {
console.log(err)
})
.then(d => console.log('What am I doing here?'));
在你的 catch 中添加一个 return
语句
.catch(err => {
console.log(err);
return;
})
当这个请求导致错误时,then 方法在 catch 方法运行之后。出现错误时如何停止运行代码?
return fetch('url here', {
credentials: "same-origin"
})
.then(res => {
return res.json();
})
.catch(err => {
console.log(err)
})
.then(d => console.log('What am I doing here?'));
在你的 catch 中添加一个 return
语句
.catch(err => {
console.log(err);
return;
})