-1

I am trying to get the response header details from a failed call to Google Endpoints using Axios. There was an exception in Google Endpoints due to rate limit exceeded (status code 429) and I'm trying to access that status code from the client side.

When I open devtools I can see that the status header is present, but after many tries I am unable to access this header with javascript (using Axios). If I log the error there are no response headers at all.

response from POST request

My issue is similar to this one: Axios get access to response header fields but it looks like their call succeeded since they are logging the response in the "then" block. However mine fails due to CORS and there is no "response.headers" object at all in the caught error in Axios.

When I parse and log the Axios error response in the console I only see the config for the request and there are no response headers to be found at all:

enter image description here

I also have added "Access-Control-Expose-Headers: status, server" to Google Endpoints to expose the "status" and "server" headers as per the accepted answer of the above post but nothing has changed.

EDIT: I also tried using an Axios interceptor to get the raw response from the server and it is undefined. There is no response at all from Google Endpoints. I'm confused why I can see the status in dev tools but there is no way to access it in the client app.

Soni Sol
  • 2,367
  • 3
  • 12
  • 23
NicoleMoore
  • 325
  • 2
  • 14

1 Answers1

1

Status is not a regular header, it's it's own thing. If you have some kind of response object, it's likely on response.status.

Evert
  • 93,428
  • 18
  • 118
  • 189
  • I do have a response object from axios which I logged above and there is no "status" inside of it at all. Only config (which is the request config for axios), a simple message, name and error stack – NicoleMoore Nov 27 '20 at 18:13
  • Adding to the above comment: I tried using an interceptor in axios to get the actual network response but the response is completely undefined. So I can not get any status or message at all – NicoleMoore Nov 27 '20 at 19:36