When using geocoding search I am able to send empty string for the parameter ‘q’ even though it’s required.
The URL used is: https://forward-reverse-geocoding.p.rapidapi.com/v1/search?q=&addressdetails=1&limit=1
As a result I get this Object:
{
“lat”: “52.720615499999994”,
“lon”: “58.66574618108943”,
“displayName”: “Sibay, городской округ Сибай, Baschkortostan, Föderationskreis Wolga, UNDEFINED, Russland”
}
(It’s in German, but yeah, it’s somewhere in Russia)
Присоединяйтесь к обсуждению – добавьте комментарий ниже:
Yes, so it’s best to first check if your variable for q (or any other field in the query) is not empty|undefined|null|none etc. (depending on the language used).
Ah, then it looks like the Angular HTTP Client automatically adds “undefined” to URLs when it detects an empty parameter. Good to know!
Also thanks for pointing it out, I printed the URL into my console before I gave it to the HTTP Client and there it didn’t contain “undefined”.
Hi Andreas, this did not happen with an empty string for q, but with a string of “undefined” (which is not undefined but just a string with the value “undefined”).
So you searched for https://forward-reverse-geocoding.p.rapidapi.com/v1/search?q=undefined&addressdetails=1&limit=1
Now “undefined” should be a stop word but currently is not (these are always hard edge cases, e.g. how would you treat a store that is called “Undefined”? We do have the same edge case with “null”).
If you do send an empty string for q at the search endpoint, you won’t get a result.