How to populate data in select dropdown field inside form from external api call response

Suppose there is filed name city…now i want to populate list of city names from my rest api which return response like c {city:[“bangalore”,“pune”,“mumbai”]}

Does this help ? Overriding Link Query By Custom Script

But how do i make api call inside doc type and it will autopopulate from the the response of rest api.
I am using frappe cloud to explore.

hmm What is the use case?

It seems Virtual DocTypes also an option here.

Let me explain clearly ,

Consider there is select field city in the form.
Now city dropwdown data should load from external rest api call /city.

When use come on form , on click on select drop down it should make ajax call and load the data in select dropdown.

Let me explain clearly ,

Consider there is select field city in the form.
Now city dropwdown data should load from external rest api call /city.

When use come on form , on click on select drop down it should make ajax call and load the data in select dropdown.

cur_frm.set_df_property("my_select_field_name", "options", ["", "Hi", "Hey"])

i think it can also be done also using frappe.model.set_value by providing the array directly

Check below code for insert_after field

where are we making api call and then setting the response of api in doctype with select field.