Created
December 2, 2016 09:26
-
-
Save surmon-china/0a51aa8e30637f249ea1cc6d1588b1a1 to your computer and use it in GitHub Desktop.
From http://stackoverflow.com/questions/34475523/how-to-pass-url-arguments-query-string-to-a-http-request-on-angular-2 ng2 http get params
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Parameters obj- | |
let params: URLSearchParams = new URLSearchParams(); | |
params.set('appid', StaticSettings.API_KEY); | |
params.set('cnt', days.toString()); | |
//Http request- | |
return this.http.get(StaticSettings.BASE_URL, { | |
search: params | |
}).subscribe( | |
(response) => this.onGetForecastResult(response.json()), | |
(error) => this.onGetForecastError(error.json()), | |
() => this.onGetForecastComplete() | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment