Closed meash-nrel closed 6 years ago
Defaults mentioned in docs aren't being applied. If I set those default values in api initial configuration, it corrects this issue.
.withDefaults({headers: {'Content-Type':'application/json', 'Accept':'application/json'}})
I output this.defaults in the request() function in aurelia-api.js and it was an empty object. Not sure how but this.defaults is going from being set in constructor to being empty object by the time I hit request().
@meash-nrel That's unfortunate, I'm sorry you're having trouble with this.
Having figured out the issue, do you feel confident submitting a PR?
Caused by #215. @netcitylife accurately identified the issue, but was ignored :(
On the linked line, the newClient.defaults
property is the empty object when it is unconfigured - not null. Then it goes on and overrides the aurelia-api
defaults with the empty object.
Workaround is to set the defaults to a falsey value in the config.registerEndpoint()
function:
plugin(
'aurelia-api',
config => {
config.registerEndpoint(
'github',
endpoint => endpoint.withDefaults(undefined)
)
}
);
@carusology Nice find. Maybe you want to contribute a more sustainable fix? It'd be much appreciated!
@RWOverdijk Is there documentation on how to run the tests anywhere?
npm install
and npm test
do not appear to be sufficient. The contributing guidelines reference running gulp
globally, but that is what npm test
is doing.
@carusology I'm pretty sure that just running yarn test
(or npm) should just work if you run jspm install first.
My code worked in 3.1.1 and earlier, but after updating to 3.2.0 latest, all POST and PUT requests in my application are broken.
The request payload is coming across as "[object Object]" instead of the expected json stringified object. Request header is getting this set to "Content-Type: text/plain;charset=UTF-8", expected it to auto-set it to "application/json" as it did before.
Reverted API (and ORM and Authentication dependencies) to 3.1.1, and those same calls are coming back with the json string in body and 'application/json' as expected.