You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My developer found an issue with the API when he was trying to create a new user. Here is his explanation below:
In the Api.prototype.request function in file plugins/request.js, util._extend method is used like this: util._extend(options, this.httpOptions);
but this only makes shallow copy of an object - meaning that this.httpOptions.headers is copied as a reference and later in the method there are lines that put options.headers['Content-Length'] = params.length;
So that last line actually modifies this.httpOptions.headers
and for later call to Api.prototype.request the previous headers are used
I had a login as a POST which were setting the headers and then I had just after that PUT which did not set the headers but because POST set the headers then PUT got the previous request headers
The fix was to replace util._extend with a function that makes deep copies of the objects and not shallow copies
installed deep-extend module that provided a short path to make deep copies of objects util._extend(options, this.httpOptions); went to deepExtend(options, this.httpOptions);
The text was updated successfully, but these errors were encountered:
We are actually working in TypeScript and have copied the API code into our program rather than using the package. I haven't had a chance to review the code where the fix was implemented yet. Once I have reviewed it I will try to fix it up and provide it as a pull request.
My developer found an issue with the API when he was trying to create a new user. Here is his explanation below:
In the
Api.prototype.request
function in file plugins/request.js, util._extend method is used like this:util._extend(options, this.httpOptions);
but this only makes shallow copy of an object - meaning that
this.httpOptions.headers
is copied as a reference and later in the method there are lines that putoptions.headers['Content-Length'] = params.length;
So that last line actually modifies
this.httpOptions.headers
and for later call to
Api.prototype.request
the previous headers are usedI had a login as a POST which were setting the headers and then I had just after that PUT which did not set the headers but because POST set the headers then PUT got the previous request headers
The fix was to replace
util._extend
with a function that makes deep copies of the objects and not shallow copiesinstalled
deep-extend
module that provided a short path to make deep copies of objectsutil._extend(options, this.httpOptions);
went todeepExtend(options, this.httpOptions);
The text was updated successfully, but these errors were encountered: