Environment WeChat Mini Programs.
Code for example:
module.exports = {
request: function(method,url,data){
return new Promise((resolve,reject)=>{
wx.request({
url:url,
method:method,
data:data,
success:function(res){
if(res.statusCode == 401){
abc();
}else{
resolve(res)
}
}
})
})
}
}
I encapsulated a promise version of WeChat Mini Programs"s request request.
wants to validate the statusCode and process it before operating.
abc () is the handler, which is processed when the code is 401.
tell me how to repeat this function when statusCode = = 401.
that is, the desired effect is to perform abc () processing when code is 401, and execute this function directly from scratch after processing.