World Cities

免费增值
通过 Andres Olvera | 已更新 5 месяцев назад | Location
人气

8.6 / 10

延迟

638ms

服务等级

100%

返回所有讨论

List of countries and cities

avatar
robin.sekvard
2 года назад

Is it possible to list all countries to dropdown component to choose the one you want and then make a list of cities to choose one according to the chosen country?

avatar
andruxnet commented 2 года назад

Hi,

Currently there’s no option to list all countries, because the query parameter is required – although the docs in the API say it isn’t but that’s because I can’t get to modify the settings of the API.

Anyway, what you can do is get a list of countries elsewhere, and then put those in your first dropdown. Then, when the user selects a country, just use it as the query param for this API and set the searchby param to “country”. This will get you a list of all cities in the selected country, then you can just grab all unique cities and show them in a second dropdown.

Hope that helps.

加入讨论 - 在下面添加评论:

登录/注册以发布新的评论
打分:5 - 投票:1