$getUrl issue when updating form 2.x to 3.x
Closed this issue · 1 comments
Hi I have the following issue. In version 2.x I had the following generic class which all of my services extended and it worked fine.
export class Rest<T> extends Resource {
oAuthService: OAuthService;
coreConfig: ConfigStoreService;
constructor(http: Http,
oAuthService: OAuthService,
coreConfig: ConfigStoreService) {
super(http);
this.oAuthService = oAuthService;
this.coreConfig = coreConfig;
}
@ResourceAction({
path: '/',
method: RequestMethod.Get
})
public getAll: ResourceMethod<RestParametersGet, RestReturnClass<T>>;
@ResourceAction({
path: '/{!id}',
method: RequestMethod.Get
})
getById: ResourceMethod<RestParametersGetUnique, T>;
@ResourceAction({
path: '/count',
method: RequestMethod.Get
})
getCount: ResourceMethod<{ includeRelated?: boolean, where?: string }, any>;
getUrl(methodOptions?: any): string | Promise<string> {
let resPath = super.getUrl();
return this.coreConfig.getConfig().api + resPath;
}
getHeaders(methodOptions: any): any {
let headers = super.getHeaders();
headers.Authorization = "Bearer " + this.oAuthService.getAccessToken();
return headers;
}
I prefixed the $ symbol on getUrl and getHeaders and eventhough the $getHeaders now is being used before any request just fine the $getUrl doesn't which means it hits every time the relative path instead of the one that's coming for the environments (this.coreConfig.getConfig().api) which is different based on the build
Hello all.
I've released some kind of beta of new library which is called rest-core
+ rest-ngx
.
Please check them rest-core
and rest-ngx
.
It works the way like ngx-resource
but has a lot of breaking changes.
Something was removed or simplified.
I've migrated all my projects to the new library.
If you wish to switch to HttpClient or use some other http handlers like fetch
try to migrate your projects to the lib.
Bugs and help requests are welcome in corresponding repos.
Thanks!
PS: Since ngx-resource
is no longer supported by me, closing the issue.