nodejs 服务器模拟异常状态码429,以及前端vue axios捕获状态码


 

 

nodejs 服务端发送429状态:

    extendInfo (req, res) {
       res.status(429).json('Too many requests, please try again later.')  
    },

 

vue客服端

export const ajaxPost=(url, params) => {
    return axios.post(ajaxIp+url, params, {
        headers: {
            // "Content-Type": "multipart/form-data"
            "Content-Type": "application/json"
        }
    }).then(res=>{
        if (data.code == 200) {
            return data.data;
        }else {
            return {code:data.code,msg:data.msg}
        }
    })
        .catch(err => {  //捕获异常状态码
            console.error(err.response.status);
        });
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM