jeudi 25 mai 2017

POST request to API from Ember often fails with 'The adapter operation was aborted Error'

I'm writing an Ember tutorial that I'd like to run on top of a very simple API I've created in Flask. PUT, DELETE, and GET requests made from ember-data behave as expected. The POST request throws an error and does not complete. The POST Ajax request is canceled before it's sent.

This behavior is intermittent. If I set a breakpoint and follow it through the Ember internals then by the time I'm done, the request will often succeed. When running the API locally the error is thrown but the new user is still written to the database. So this feels like client-side async weirdness but I'm lost on how to proceed.

I can successfully complete a POST request using curl, from postman and from the console in Chrome using JQuery. The preflight OPTIONS request succeeds. My API is set up for CORS and returns an 'Access-Control-Allow-Origin' header of '*' and an 'Access-Control-Allow-Headers' of 'content-type'. There is no content security policy set up on the Ember app.

My API is here:

GitHub: http://ift.tt/2r2GU1j

My Ember app is here:

GitHub: http://ift.tt/2s0rVCz




Aucun commentaire:

Enregistrer un commentaire