When working with my service.ts file, I encountered an issue while calling a method that triggers an http request to the specified API endpoint:
users/1111/state/2222
The numbers 1111 and 2222 represent the userId and stateId respectively.
This is the snippet of code from my service.ts file:
public getParams(userId: number, stateId: number): Observable<MyModel> {
return this.get(`users%2F${userId}final-rosters%2F${stateId}`)
.pipe(map(response => response.body));
}
Now, in my component.ts file. I am invoking the above method in this manner:
public getUser(
userId: number,
stateId: number,
): void {
this.myService.getParams(userId, stateId)
.subscribe(result => {
this.myModel.next(result);
console.log('GET DATA ', result);
});
}
After inspecting the tools, I noticed the following URL path being generated:
I am currently facing challenges in converting the given URL path into one that correctly incorporates the two required parameters.