jeudi 24 mars 2016

Retrying request from Ember Data

I have an ember app with a rails backend.

I have a specific error that Rails can return (401) that I would like Ember to catch and act upon. In that case I would like to perform a custom method (which essentially modifies the request cookie) and then makes the request again.

Right now I am catching this error at the top level router and forcing the entire app the reload with window.location.reload(). Obviously this is a terrible hack. I was not able to get router.refresh() to work, but that would still be a hack anyway.

Ideally I would catch this much closer to the adapter so I can act on it. Perhaps I could catch this instead at the adapter level by overriding handleResponse(), but how would I retry the request from there?

http://ift.tt/1RnQIWA handleResponse does pass along the requestData, but I would need some way to perform the request in the context of the adapter's methods, right?




Aucun commentaire:

Enregistrer un commentaire