zoukankan      html  css  js  c++  java
  • 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);
            });
    }
  • 相关阅读:
    Mysql 删除表
    Mysql 创建表
    Mysql left join
    Qt(Mac) 进程的启动
    Mysql update
    Mysql insert
    Mysql select
    Mysql INNER JOIN
    Mysql 别名
    Mysql 排序
  • 原文地址:https://www.cnblogs.com/web-fusheng/p/10799223.html
Copyright © 2011-2022 走看看