1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

How to pass url arguments (query string) to a HTTP request on Angular?

Discussão em 'Angular' iniciado por Miguel Lattuada, Julho 20, 2025.

  1. I would like to trigger HTTP request from an Angular component, but I do not know how to add URL arguments (query string) to it.

    this.http.get(StaticSettings.BASE_URL).subscribe(
    (response) => this.onGetForecastResult(response.json()),
    (error) => this.onGetForecastError(error.json()),
    () => this.onGetForecastComplete()
    )


    Now my StaticSettings.BASE_URL is like a URL without query string like: http://atsomeplace.com/ but I want it to be like http://atsomeplace.com/?var1=val1&var2=val2

    How to add var1, and var2 to my HTTP request object as an object?

    {
    query: {
    var1: val1,
    var2: val2
    }
    }


    and then just the HTTP module does the job to parse it into URL query string.

    Continue reading...

Compartilhe esta Página