Angular 4 HttpClient Query Parameters

Discussão em 'Angular' iniciado por joshrathke, Maio 12, 2025.

  1. joshrathke

    joshrathke Guest

    I have been looking for a way to pass query parameters into an API call with the new HttpClientModule's HttpClient and have yet to find a solution. With the old Http module you would write something like this.

    getNamespaceLogs(logNamespace) {

    // Setup log namespace query parameter
    let params = new URLSearchParams();
    params.set('logNamespace', logNamespace);

    this._Http.get(`${API_URL}/api/v1/data/logs`, { search: params })
    }


    This would result in an API call to the following URL:

    localhost:3001/api/v1/data/logs?logNamespace=somelogsnamespace

    However, the new HttpClient get() method doesn't have a search property, so I am wondering where to pass in the query parameters?

    Continue reading...

Compartilhe esta Página