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
Optional fetch with credentials #301
Optional fetch with credentials #301
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
One question. Maybe we should reconsider in the next major version how to define some header values?
Maybe one option on each service with the name "headers" and you can set your own values. It would be totally generic but for each service the same instead each service provides own options like apiKey...
Thanks for this update!
Hi there! Thanks for the contribution! @mcclurec @D4rkiii I'm working on improving the custom services dev and I pushed the first part earlier. I'm currently working to add a global mixin that, among other things, provides a fetch method with some pre-configured option like that. @mcclurec I will integrate your work in it if you are ok with it ? |
@bastienwirtz I like it. I initially though about wrapping all of My one piece of feedback is to make it as faithful a reproduction of the native
Feel free to close this PR in favor of your own |
@bastienwirtz I refactored my PR to utilize the Let me know if you have strong opinions about either of those choices. My thought is that it would be better to get this out in the community now and fix the CORS issues, and if we later want to refactor the mixin to handle more of the data fetching nitty gritty, we can do that in a separate PR. |
Hey @mcclurec, The mixin is a shortcut, and even if it's 100% compatible with the native fetch signature, it's not meant to be a generic replacement. It provides the error checking and json decoding, which is useful for ALL services so far (with the boolean to handle specific case, and beyond that you the native fetch is still here if something), that's our use case here. It helps standardize all services implementation and ease the custom service development. |
All right, I finally pushed the last parts of the re-factorization to use the internal fetch method & the Generic template as a base. Credential include is now optional and service code is much smaller. We can close this issue. |
Description
Follow up to PR 291. Adding
credentials: 'include'
to all fetch calls had unexpected CORS side effects for users. This PR introduces a global mixin to expose afetchOptions
helper method on all components. "Service" items can now include afetchWithCredentials
prop on their config entry which will add the fetch option as needed.Fixes # Issues 296 and 297
Type of change
Checklist:
config.yml
file