Search code examples
javascriptangulartypescriptangular-routingangular9

Angular 9 get data with querystring params


I am trying to get data from search API. The search value is passed as a query string.

No errors at compile time, no errors at runtime.

const params = new HttpParams().set('search', 'pizza');
this.http
    .get('/hello', { responseType: 'json', params })
    .subscribe(console.log, console.log);

Generates the /hello GET query but without the query string parameters.

What's wrong?

Angular exact version is 9.1.11

EDIT

The issue does not come from Angular but on how I try to embed the app. It works when using the default dev server without trying to embed it.


Solution

  • There is no issue with Angular or the syntax I am using. The issue came from the integration I tried to do. I tried to embed the Angular App in a web page and develop from there.

    It doesn't seem to be a good idea.

    Everything work with the default dev server.