-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
Unable to change Content-Type header #16
Comments
It's a bit of a pain with the current release...but there's a new release coming today or tomorrow morning. With that version it's really easy. You can configure headers to be used by all requests, or per-request. Here's is a header that will be used for every request: var client = new HttpClient()
.configure(x => {
x.withBaseUrl(baseUrl);
x.withHeader('Authorization', 'bearer 123');
});
client.get('some/cool/path'); The configure API will let you set up options to be used on all requests. The same API is available per-request though. So, instead of calling var client = new HttpClient()
.configure(x => {
x.withBaseUrl(baseUrl);
});
client.request
.withHeader('Authorization', 'bearer 123')
.get('some/cool/path'); So, in this case the Hope that makes sense. This is part of a major overhaul to the http client. It's releasing today or tomorrow. |
Thank you, it totally makes sense for me. I'm looking for the new release ;) |
Ditto. And can I tell you how much I'm loving Aurelia? I've been playing with it extensively for the past 48 hours and it's just flat out fantastic. |
Awesome! We still have a lot of work to do but I'm encouraged by the community response. If you can stick around while we work out the kinks....I think we're going to have something really nice. |
Hi! I'm not able to set a header on 0.5.2, neither by using the configure function nor the withHeader function: import {HttpClient} from 'aurelia-http-client';
export class Spacemoney{
static inject() { return [HttpClient]; }
constructor(http) {
this.env = 'development';
this.apiToken = '...';
this.http = http.request.withHeader('Authorization', 'Token token="' + this.apiToken + '"');
}
...
} When the request is made, no Authorization header is set. Let me know if there's any more information I can provide that would help. BTW, I have been building a sideproject using Aurelia for the past 72 hours, and I am in love. I'm so excited to see this project mature! |
We have unit tests that do just this, so that's a little baffling. Is it possible for you to write a test case for us that fails? |
I would like to override Content-Type header when using this.http.put() and post.
The default content type is
"text/plain;charset=UTF-8"
but I need"application/json"
.I tried to attach
.withHeaders({ "Content-Type": "application/json" })
to put method, but it didn't work.Please provide a way to set this header. Thanks!
The text was updated successfully, but these errors were encountered: