-
-
Save MiguelLattuada/bb502d84854ad9fc26e0 to your computer and use it in GitHub Desktop.
Adding parameters to HTML get request on Anuglar 2
This file contains hidden or 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
public getForecast(days: number) { | |
// 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