Newer
Older
This file handles actions for the cities redux state
*/
import axios from 'axios'
import { AppDispatch } from './../store'
import Types from './types'
/** Action creator to get all cities from api and send appropriate actions to reducer */
export const getCities = () => async (dispatch: AppDispatch) => {
await axios
.then((res) => {
dispatch({
type: Types.SET_CITIES,
payload: res.data.items,
})
dispatch({
payload: res.data.total_count,
})
dispatch({
})
})
.catch((err) => console.log(err))
}