Closed rec-app closed 3 years ago
Hi @rec-app geonames.js relies on the axios library to make api calls to geonames Webservices, and in axios you should be able to make api requests with multiple query strings with the same key like in your example, by using an array of strings.
try something like this:
this.geonames.search({ country: country, q: search, featureCode: ['ADM2, 'ADM1'] })
Great minds think alike!
I did try that unfortunately the resulting request url is featureCode[]=ADM2&featureCode[]=ADM1 which returns all feature codes. Where featureCode=ADM2&featureCode=ADM1 returns the correct results.
Checked out that StackOverflow link and it seems like you can use new URLSearchParams
or "you can override params serialization and then use QS NPM module to serialize array with repeat mode"
let myAxios = axios.create({
paramsSerializer: params => Qs.stringify(params, {arrayFormat: 'repeat'})
})
myAxios.get('path/to/api/',{params}) // URL : https://path/to/api?foo=5&foo=2
Hey @rec-app i've just published a new release with the change. it should work now, let me know :)
@kinotto that did the trick, thanks for implementing that so quickly!
I am looking to pass multiple featureCodes as params to the search api end point. I don't seem to be able to do this?
Example:
this.geonames.search({ country: country, q: search, featureCode: 'ADM2', featureCode: 'ADM1' })