Closed rmaclean-ee closed 6 years ago
Hello Robert,
Thanks for your contribution. I'm currently on vacation. I'll look into it in two weeks!
Robert MacLean notifications@github.com schrieb am Mo., 25. Juni 2018, 12:04:
Related to #36 https://github.com/christianmalek/vuex-rest-api/issues/36
This is to allow the use of dynamic headers to be passed through from the request by extending ShorthandResourceActionOptions with a property for headers. This property follows the same design as the path so it is Function|Object which lets you pass in a static or dynamic header.
Example usage of static header key and value
.get({ action: 'getData', property: 'stocks', path: '/stock', queryParams: false, headers: { 'X-Stock': 'MSFT' } })
Example usage of dynamic header value
.get({ action: 'getData', property: 'stocks', path: '/stock', queryParams: false, headers: ({ stockCode }) => ({ 'X-Stock': stockCode }), })
stockCode in the above example comes from the same parameter bag as would be used for paths.
You can view, comment on, or merge this pull request online at:
https://github.com/christianmalek/vuex-rest-api/pull/66 Commit Summary
- Adding support for allowing headers to be passed in as an option
- Updated distribution version
File Changes
- M .gitignore https://github.com/christianmalek/vuex-rest-api/pull/66/files#diff-0 (3)
- M dist/Resource.d.ts https://github.com/christianmalek/vuex-rest-api/pull/66/files#diff-1 (1)
- M dist/Resource.js https://github.com/christianmalek/vuex-rest-api/pull/66/files#diff-2 (18)
- M package.json https://github.com/christianmalek/vuex-rest-api/pull/66/files#diff-3 (1)
- M src/Resource.ts https://github.com/christianmalek/vuex-rest-api/pull/66/files#diff-4 (20)
Patch Links:
- https://github.com/christianmalek/vuex-rest-api/pull/66.patch
- https://github.com/christianmalek/vuex-rest-api/pull/66.diff
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/christianmalek/vuex-rest-api/pull/66, or mute the thread https://github.com/notifications/unsubscribe-auth/ACvaggpEyvWVesj9rXbbOPFVdrJk01cdks5uALW1gaJpZM4U13Ej .
Thanks @rmaclean-ee,
it's now available via version 2.8.0 :)
Related to https://github.com/christianmalek/vuex-rest-api/issues/36
This is to allow the use of dynamic headers to be passed through from the request by extending
ShorthandResourceActionOptions
with a property for headers. This property follows the same design as thepath
so it isFunction|Object
which lets you pass in a static or dynamic header.Example usage of static header key and value
Example usage of dynamic header value
stockCode
in the above example comes from the same parameter bag as would be used for paths.