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

RequestMemory does not honor HTTP headers #245

Open
bosticka opened this issue Sep 8, 2021 · 0 comments
Open

RequestMemory does not honor HTTP headers #245

bosticka opened this issue Sep 8, 2021 · 0 comments

Comments

@bosticka
Copy link

bosticka commented Sep 8, 2021

if I do this:

                new RequestMemory({
                    idProperty: 'id',
                    target: target
                    headers: { Authorization: 'Bearer abcd' }
                })

The bearer token for my JWT is not sent with the request and fails against an authenticated API.

I had to make two small changes to get this to work.

In RequestMemory.js:

postscript: function () {
			this.inherited(arguments);
			this.fetch();
		},

changed to:

postscript: function () {
			this.inherited(arguments);
			this.fetch(arguments[0]);
		},

and in Request.js:

		_request: function (kwArgs) {
			kwArgs = kwArgs || {};

			// perform the actual query
			var headers = lang.delegate(this.headers, { Accept: this.accepts });

changed to:

		_request: function (kwArgs) {
			kwArgs = kwArgs || {};

			// perform the actual query
			var headers = lang.mixin(this.headers, { Accept: this.accepts });

The lang.delegate breaks it somehow. It returns a TMP object and the passed in headers do not get mixed in and sent to the server.

Please consider merging these changes.

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