ember-cli / ember-fetch

HTML5 fetch polyfill from github wrapped and bundled for ember-cli users.
MIT License
176 stars 82 forks source link

beforeSend option #222

Open miguelcobain opened 5 years ago

miguelcobain commented 5 years ago

Seems that some addons like ember-simple-auth make use of the beforeSend option. This option works on jquery ajax: http://api.jquery.com/jQuery.ajax/

Here, for example: https://github.com/simplabs/ember-simple-auth/blob/master/addon/mixins/data-adapter-mixin.js#L97

Would it make sense for AdapterFetch to try to use this option?

At the moment, I don't think it is possible to use ember-simple-auth + ember-data + ember-fetch?

xg-wang commented 5 years ago

It's also used in ember-data JSONAPIAdapter, and lots of other addons.

ajaxOptions in the fetch adapter doesn't call super, so other addon's mixins and ember-data's hash w/ beforeSend won't be mixed into ajaxOptions. I'm not sure whether this should happen in the adapter level or we provide such a hook in a fetchService. @rwjblue @nlfurniss Do you have any idea about this?

nlfurniss commented 5 years ago

@xg-wang other ajaxOptions are def called (the adapter mixin has to be in the correct order).

beforeSend isn't necessary here since the addon could instead change the options passed into ajaxOptions. This would be a code change that would allow it to work with ember-fetch and jQuery.

However, $.prefilter doesn't have any support yet. I'm writing an RFC for how we want to handle prefilter in a jQuery-less world. Keep an eye out :-)