Here is my instance of axios in react app. What I want to do is to catch errors from server and base on error silence it. For instance if user with this name is existed I want to silence error and just return alert message. But interceptor doesn't trigger:
import axios from "axios"; const instance = axios.create({ baseURL: "http://localhost:8000", withCredentials: true, timeout: 1000 }) instance.interceptors.request.use( request => request, error => { console.log(error) console.log(error.response) console.log(error.response.message) return { data: { status: 'fail' } }; } ) export default instance For now I just want console.log it, but it still breaks the whole logic and throws an error ((
https://stackoverflow.com/questions/66701552/how-correctly-to-use-interceptorce-with-axios-react March 19, 2021 at 09:55AM
没有评论:
发表评论