标签:ams .post class catch 状态码 ror return headers ==
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); }); }
nodejs 服务器模拟异常状态码429,以及前端vue axios捕获状态码
标签:ams .post class catch 状态码 ror return headers ==
原文地址:https://www.cnblogs.com/web-fusheng/p/10799223.html