fetch('xxxurl.com').then(res=>{ if(res.status === 'ok') { console.log('我应该如何跳出,不执行下一个then?');
} else { return 'ok,可以继续';
}
}).then(res=>{ console.log(res);
});我希望根据状态来判断是否要执行接下来的then,应该怎么做?
1 回答

湖上湖
TA贡献2003条经验 获得超2个赞
这样算不算一种方式:
fetch('1.png') .then(function(){ console.log(arguments); throw new Error('test'); }) .then(function(){ console.log('end') }) .catch(function(exc){ console.log(exc); });
添加回答
举报
0/150
提交
取消