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);
        });
}