This function returns an array with the cities of the given state
Parameters
stateObject
Object The object the tells the name of the state.stateObject.state
string The state name. (optional, defaultrequiredParam('state')
)
Examples
const cities = api.getStateCities({ state: 'São Paulo' });
// { state: 'São Paulo', abbreviation: 'sp', cities: ['Santos', 'São Vicente', 'Guarujá',...] }
Returns stateType?
This function receives the city name and returns the full json stateType object or only the name of the state depending on shouldReturnEntireJson property. If the state is not found, it returns an empty object or an empty string.
Parameters
cityObject
Object The object the tells the name of the city and if the return should be an object or just a string.cityObject.city
string The city name. (optional, defaultrequiredParam('city')
)cityObject.shouldReturnEntireJson
boolean This property tells to the method that the return should ou should not be the full state object. If the property is true, it will return the entire stateType object, if its false or not set, it will return just the string with the name of the state. (optional, defaultfalse
)
Examples
const cities = api.getCityState({ city: 'Santos', shouldReturnEntireJson: true });
// { state: 'São Paulo', abbreviation: 'sp', cities: ['Santos', 'São Vicente', 'Guarujá',...] }
const cities = api.getCityState({ city: 'Santos' });
// 'São Paulo'
const cities = api.getCityState({ city: 'Santos', shouldReturnEntireJson: false });
// 'São Paulo',
const cities = api.getCityState({ city: 'randomCity' });
// ''
const cities = api.getCityState({ city: 'randomCity' , shouldReturnEntireJson: false});
// ''
const cities = api.getCityState({ city: 'randomCity', shouldReturnEntireJson: true });
// {}
Returns (string | stateType | {})
Type with state name, abbreviation and cities
Type: Object
Properties
cityName
stateType Name of the city, the name of the city is dinamic, e.g: Santos: stateType
Type with state name, abbreviation and cities
Type: Object
Properties
stateName
stateType Name of the city, the name of the city is dinamic, e.g: São Paulo: stateType
Type with state name, abbreviation and cities
Type: Object
Properties