Tell me how to add parameters to the url for the request to the API in this method:

public get(url: string = ''): Observable<any> { this.user = this.store.snapshot().user; console.log(this.user); const userId = this.user.userId; return this.httpClient.get(this.getUrl(url)); } 

I want to add userId to the query string, for example: home / position? UserId = 133r4322r34

  • one
    const params = new HttpParams().set('userId', '133r4322r34'); return this.http.get(url, { params }) const params = new HttpParams().set('userId', '133r4322r34'); return this.http.get(url, { params }) - overthesanity
  • Thank! Works - Vyacheslav

0