有時,我們的背景接口有權限的限制,不滿足權限,就傳回錯誤碼401,那麼在js中如何判斷呢?

if ((data.status && data.status == '401') || (data.statustext && data.statustext == 'no transport')) {
console.log(data);
var currenturl = window.location.href;
window.location.href = currenturl;
return;
}
下面是真實的傳回:
object {readystate: 4, responsetext: "", status: 401, statustext: "unauthorized"}

if(stringutil.isnullorempty(token)){//added by huangwei
logger.error("token is null");
response.setstatus(401);
return false;
}