I have been looking for a way to pass query paramters 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?
If you have an object that can be converted to
{key: 'stringValue'}
pairs, you can use this shortcut to convert it:I just love the spread syntax!