City Fetcher API

Easy

Prompt

You have two async APIs that provide geographic data:

  • getStates(country) returns a promise resolving to the state codes for that country (e.g. ['CA', 'NY', 'WA'] for 'USA'), or an empty array for an unknown country
  • getCities(state) returns a promise resolving to an array of city names for that state

Implement a function getAllCities(country) that:

  • Fetches all states for the given country
  • Fetches cities for every state in parallel
  • Returns a promise resolving to a single flat array of all city names, in state order