Skip to content

Instantly share code, notes, and snippets.

@MiguelLattuada
Created December 26, 2015 22:22
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MiguelLattuada/bb502d84854ad9fc26e0 to your computer and use it in GitHub Desktop.
Save MiguelLattuada/bb502d84854ad9fc26e0 to your computer and use it in GitHub Desktop.
Adding parameters to HTML get request on Anuglar 2
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