解决vue+axios请求报错POST http: net::ERR_CONNECTION_REFUSED,在封装的请求中统一处理请求异常的问题

2020-09-28 10:51:00 浏览数 (1)

如何在Axios中处理net :: ERR_CONNECTION_REFUSED-Vue.js - SamYoc 有壳 

https://www.samyoc.com/single/4016

您可以使用拦截器:

代码语言:javascript复制
axios.interceptors.response.use(
    response => {
        return response
    },
    error => {
        if (!error.response) {
            console.log("Please check your internet connection.");
        }

        return Promise.reject(error)
    }
)

0 人点赞