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

Add a way to set default options #68

Closed
garygreen opened this issue Jul 28, 2018 · 6 comments
Closed

Add a way to set default options #68

garygreen opened this issue Jul 28, 2018 · 6 comments

Comments

@garygreen
Copy link

Just like you can with jQuery's $.ajaxSetup() or various ways to set axios defaults

This would be very useful for when you want to always send e.g. CSRF token or certain headers, etc.

@cferdinandi
Copy link
Owner

You could save your options to a var and pass that in?

I'm not open to supporting this feature at this time. Sorry!

@garygreen
Copy link
Author

You could save your options to a var and pass that in?

The main problem comes with merging the default options with the custom options your using for the request. You have a extend function built into atomic which already handles it. Not sure why your not open to supporting the feature which would add zero bloat to the library, it's just a case of allowing consumers to access the defaults of atomic...

@garygreen
Copy link
Author

I'll just fork the library and hack away on it with various features as you don't seem very open to suggestions. Grateful for all your work on the library though, it's super awesome 😄

@cferdinandi
Copy link
Owner

cferdinandi commented Jul 28, 2018

I think this makes sense more in the context of #69.

Otherwise, I don't see how this saves any work vs. setting your options to a variable if you want to reuse them, no?

@cferdinandi
Copy link
Owner

This seems to only make sense in the context of #69. Otherwise, I'm not sure how this is any more efficient than setting your options to a variable for reuse.

@garygreen
Copy link
Author

garygreen commented Jul 28, 2018

atomic('https://test.com/users/save', { method: 'POST', headers: { 'Custom-Header': 'blah' }});

How would you merge the default headers with your custom ones as above? You would need to do a deep merge of some kind, or manually merge each property. That functionality is already inside Atomic I believe so it would be nice to leverage that, somehow.

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

2 participants