How to create two cascading dropdown where both dropdown value coming from Rest API

Suppose I have two dropdown Country and State. Based on the country selection state will populate. and all the value of state and country drop down will come from rest api. I have a form of employee details, where I want to put these two drop down ,state and country. Give me solution how to to populate these two dropdown value and also how  to save selected state and country of employee.
1 answers
  1. If the REST API is external source
    1. You must first consume the REST, by creating a JSON mapping, Import mapping, entity definitions needed etc
    2. Call the REST service, with the import mapping fill the data in your database
    3. Then with Reference selectors you will be able to show the data
  2. If the REST API is within the same Mendix app (I am very much hoping its not)
    1. Then you must already have the data
    2. Use Reference selectors to show the data


For your mapping to work;

  1. Country entity and State entity should be associated to each other
    1. Like 1 Country can have multiple States
  2. Employee should also be associated with State
    1. Like 1 state can have multiple employees