title: How to include parameter in HTTP request with Angular 6
body: <p>I need to call the following endpoint <code>https://sample_url?id=12345</code> from an Angular service. </p>
  
  <p>UserService </p>
  
  <pre><code>getUsersByGroupID(id): Observable&lt;User[]&gt; {
   var url = 'https://sample_url';
  
   var params = new HttpParams();
   params = params.append('id', id);
  
   this.data = this.http.get&lt;User[]&gt;(url, {params: params}, this.httpConfig.getHeaderOptions()).pipe(catchError(this.handleError('getData', [])));
   return this.data;
  }
  </code></pre>
  
  <p>In one of my components I should do something like... </p>
  
  <pre><code>  this.userService.getUsersByGroupID(sys_id).toPromise().then(users =&gt; {
     this.users = users as User[]
  }
  </code></pre>
  
  <p>but i'm not sure how to include the query parameter <code>?id=</code>correctly. I tried looking at <a href="https://stackoverflow.com/questions/34475523/how-to-pass-url-arguments-query-string-to-a-http-request-on-angular">How to pass url arguments (query string) to a HTTP request on Angular</a> but didn't help much. </p>
  
  <p>Thanks.</p>