Home > Back-end >  Http GET query parameter with "false" value is disappeared
Http GET query parameter with "false" value is disappeared

Time:01-06

Having a get request

this.http.get(`/writers/rating/`, { params: { probation: 'false' } })

The URL in the in the end will be not '/writers/rating?probation=false' instead it skips the falsy query parameter '/writers/rating'. Why is that? Does that have something to do with the Url-encoding?

CodePudding user response:

URLs are strings and all values in a URL are strings. So, when you are pass boolean value as query param then it will ignore it.

So your code should like below:

this.http.get(`/writers/rating/`, { params: { probation: 'false' } })

CodePudding user response:

This error was project-related so the parameters with 'false' value were striped out in the interceptor.

  • Related