JSFiddle - React, Tailwind, and code Playground
JavaScript
// 1
export function fetchContacts(){
return dispatch => {
dispatch({
type: 'FETCH_CONTACTS',
payload: axios.get(url)
})
}
}
// 2
export function fetchContacts(){
return {
type: 'FETCH_CONTACTS',
payload: axios.get(url)
}
}
// 3
export function saveContact(contact) {
return dispatch => {
return dispatch({
type: 'SAVE_CONTACT',
payload: axios.post(url, contact)
})
}
}
// 4
export function saveContact(contact) {
return {
type: 'SAVE_CONTACT',
payload: axios.post(url, contact)
}
}