Reputation: 21
EDIT: Postman/Browsers received valid response bodies from Amazon API Gateway endpoint. Other web applications do not. Basic GET with no headers. No authentication required on API endpoint. JSON data.
OP:I'm leveraging Axios for CRUD in a new VueJS application. Axios needs to be able to query an API (Amazon API Gateway). Currently I have a very basic Vue component that queries data and on response prints it to the console.
axios.get('https://myamazonurl.com/api/resource')
.then(response => console.log(response))
.catch(error => console.log(error))
The Amazon API uses no Authentication and is public-facing. I can input the above URL into either a browser or Postman and I receive the appropriate response. However, Axios returns a response with no body (the header is correct, including correct response length value), but no content. If I replace the URL with any other API, the response body is fine. Also, using jquery/AJAX or fetch also produces a body with no response, but pointing either at a different API produces data.
Upvotes: 1
Views: 871
Reputation: 21
Turns out I was using a broswer extension that ignored CORS and surpressed CORS warnings/errors. I modified the CORS policy for my API Gateway and the issue went away.
Upvotes: 1