Skip to content

CAN NOT GET THE RESPONSE DATA WHEN RESPONSE STATUS CODE 4xx #6736

Open
@TQLeung

Description

Environment

  • Axios Version 0.27.2
  • Target platform Browser
  • Adapter HTTP
  • Additional Library/Framework Versions [Actix-web + Vue3]
  • OS: Win11

I can not get the response data when the status code is 400 or 403 with axios?
It can get the response data in 200, why not in 4xx?

BUT I can get the response data by the POSTMAN in the same REQUEST in 4xx.

const service = axios.create({
  baseURL: API_BASE_URL,
  // withCredentials: false
});
service.interceptors.response.use(
  (res) => {
    return res;
  },
  (error) => {
    console.log('error',error.response.data)     # THAT IS UNDEFINED
    return Promise.reject(error);
  }
);

image

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions