MartinsOnuoha / countriesNowAPI

CountriesNow is an Open source API for retrieving geo-information for countries, including their states, cities, population, etc. 🌎
http://countriesnow.space
MIT License
185 stars 59 forks source link

Unable to get cities by state when the state name contain the word state #110

Closed pmutshipayi closed 2 years ago

pmutshipayi commented 2 years ago

When trying to get cities by state, if the state name contains the word state the request fail with error state not found

Example 1:

https://countriesnow.space/api/v0.1/countries/state/cities payload

{
    "country": "Micronesia",
    "state": "Pohnpei State"
}

Example 1:

https://countriesnow.space/api/v0.1/countries/state/cities payload

{
    "country": "Micronesia",
    "state": "Pohnpei State"
}

response:

{
    "error": true,
    "msg": "state not found"
}




Example 2:

https://countriesnow.space/api/v0.1/countries/state/cities

payload

{
    "country": "South Africa",
    "state": "free state"
}

Response:

{
    "error": true,
    "msg": "state not found"
}
MartinsOnuoha commented 2 years ago

Hi @pmutshipayi , Thanks for reporting this bug, apparently we were formatting payload that includes "state". Mostly because not a lot of state names end with "state", I guess we forgot free state was a state (lol). I've opened a new MR to resolve this problem. Feel free to have a look and approve it.