Closed a-radys closed 5 years ago
Hi @aradys , are you still experiencing this issue? I Have just checked the code and the beforepath should be correctly set...
This is Service
class delete method:
public delete(id: string, params?: Object): Observable<void> {
params = { ...{}, ...Base.ParamsResource, ...params };
// http request
let path = new PathBuilder();
path.applyParams(this, params);
path.appendPath(id);
...
And this in path-builder.ts
:
public applyParams(service: Service, params: IParamsResource | IParamsCollection = {}) {
this.appendPath(service.getPrePath());
if (params.beforepath) {
this.appendPath(params.beforepath);
}
this.appendPath(service.getPath());
if (params.include) {
this.setInclude(params.include);
}
}
I have just tested it and it's working fine... if the problem persists, maybe you can send a plunkr to test.
It's still not working. I found out that my beforepath
is set in params like this:
params: {
beforepath: ""
id: ""
include: []
params: {beforepath: "setup"}
ttl: null
}
so it fails in PathBuilder.prototype.applyParams
in line 157:
if (params.beforepath) {
this.appendPath(params.beforepath);
}
Is it possible to set default beforepath
in the service for all operations? Not to set it each time for each delete
. Maybe that would solve the issue.
Yes @aradys, you can set a method on your service:
export class AuthorsService extends Service<Author> {
public resource = Author;
public type = 'authors';
public getPrePath() {
return 'foo_path/bar_path';
}
}
Also, remember you have global cofiguration:
NgxJsonapiModule.forRoot({
url: '//api.yourserver.com/v1/foo_path'
}),
Hello, How can I set beforepath when deleting a record? I tried to do it like in all method:
this.setupService.delete(id, { beforepath: 'setup' })
but the path is not changed so it doesn't work.