
不需要处理错误逻辑时,也不影响代码执行,但是控制台报一大片红也很难受。
出现场景:
const response=await this.util.getData(apiConfig.commomCode,{});
处理方法:我们需要进行错误捕获,即catch捕获
try{
const response=await this.util.postData(apiConfig.creat,req)
}catch(e){
console.log(e.message);
}
网友评论