0

Is there a function that lets you get the status code of an api request after it has been made? I've been getting my status code 200 from response.status, but if the request fails with a 404 or a 500 I don't get a response at all. Thus, not able to get the status code.

Any recommendation on how to detect these status codes of axios requests once they fail? I want the specific number 404 or 500 for each request and response.

Jpark9061
  • 924
  • 3
  • 11
  • 26

1 Answers1

0
try {
  await axios.get(..)
} catch (error) {
  // response is in error.response
}
Evert
  • 93,428
  • 18
  • 118
  • 189