Angular 4 HttpClient Query Parameters

后端 未结 8 933
耶瑟儿~
耶瑟儿~ 2020-11-29 16:00

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

相关标签:
8条回答
  • 2020-11-29 16:49

    If you have an object that can be converted to {key: 'stringValue'} pairs, you can use this shortcut to convert it:

    this._Http.get(myUrlString, {params: {...myParamsObject}});
    

    I just love the spread syntax!

    0 讨论(0)
  • 2020-11-29 16:50

    search property of type URLSearchParams in RequestOptions class is deprecated in angular 4. Instead, you should use params property of type URLSearchParams.

    0 讨论(0)
提交回复
热议问题