0

I am trying to send query parameters with a get request. This code always has an empty query {}. What am I missing?

let p = new HttpParams().set('Test', "7878");
return this.http
  .get<Response>(environment.baseAPIUrl + route, 
    { 
      withCredentials: false, 
      headers: requestHeaders, 
      params: p, 
      responseType, 
      observe: observe as 'body'
    } 
  );
3
  • What do your mean with This code always has an empty query {}.?. How did you check it? Commented May 13, 2020 at 15:25
  • oh, I have an event object that I am just dumping to the log. Its an AWS lambda called from angular query: {}, path: {}, called from postman query: { test: '34534' }, path: {}, Commented May 13, 2020 at 15:59
  • You should check the network tab of your browser's dev-tools to see what it is actually sending - maybe the issue is on the server side... Commented May 13, 2020 at 16:01

1 Answer 1

1

Basically your use of HttpParams seems okay and it's working for me.

Open my Stackblitz Example:

  • open the dev-tools (F12 in Chrome)
  • go to the network tab
  • now Refresh the stackblitz-browser frame: everything looks good:

enter image description here

just note, that the error-message (1) will not include the url-parameters

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.