Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixing in data for every request #65

Open
ghost opened this issue Nov 26, 2015 · 1 comment
Open

Mixing in data for every request #65

ghost opened this issue Nov 26, 2015 · 1 comment

Comments

@ghost
Copy link

ghost commented Nov 26, 2015

Hi There,

I have some data relating to authorization that needs to be included in every ajax request. How would I include this in a base class without having to include it in every single one of my models.

For example:

client_id: 'myAppId'

should be part of every ajax request.

I had a look at ajaxConfig .. but this only lets me set headers and and xhr options, but does not seem to provide a way to include data.

I also looked at the "request" module on npm, but even there I couldn't find a neat way to always inject some data into every request.

In AngularJS I saw an example of an "authentication injector service" ... how would I achieve this with Ampersand?

Thanks,

Oliver

@wraithgar
Copy link
Contributor

Altering the data of a model before going to and after coming from the server is typically handled by serialize and parse, respectively. Would this work for your case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant