-
Notifications
You must be signed in to change notification settings - Fork 46
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
Not taking previously set headers into account #66
Comments
Hi! To use custom Http please try to inject it into the resource constructor and add the resource to your providers list manually (add parameter @ResourceParams({
url:BASE_API+"/users",
add2Provides: false
})
export class UserResource extends Resource {
constructor(http: CustomHttp, injector: Injector) {
super(http, injector);
}
@ResourceAction({
isArray: false
})
query: ResourceMethod<IUserQueryInput, IUserShort[]>;
} |
Hi, thanks for the explanation! As for this issue and headers, setting headers manually on a resource is not really something you should do if it works in other places throughout the app without doing it. That's kinda the point of DI. Injecting RequestOptions somewhere here and taking them into consideration in getHeaders etc. could do the trick. I wanted to do it actually, but after cloning the repo I'm getting ngc errors (and also, angular peer deps need an update as well)... |
The library doesn't take previously set headers into account (maybe RequestOptions in general). In my app, I have overloaded BaseRequestOptions, which means that each instance of RequestOptions instantiated through the app will use that as base. Resource just ignores it and gets empty headers instead.
Also, I have injected another CustomHttp in place of Http:
which also sets some specific headers. These headers are also ignored, even though the injected instance is indeed CustomHttp (checked it).
P.S. The idea with CustomHttp is to use it in separate places instead of providing it in place of Http, does this library support choosing a different implementation of Http at the moment?
The text was updated successfully, but these errors were encountered: