can you supply a example with `utils/api` {get}
jiqimaogou opened this issue · 1 comments
jiqimaogou commented
can you supply a example with `utils/api` {get}
fabriziomoscon commented
I am not sure if this help, but in my app I am using it as follows with "redux-thunk": "~2.2.0"
import {
get as apiGet,
patch as apiPatch,
} from '../utils/api'
export function APIfindProfileInfo() {
return function(dispatch, getState) {
dispatch(loadProfileStart())
return apiGet('https://yourdomain/accounts?id=1', false)
.then(data => {
if (!data || !data.account_profile) {
dispatch(loadAccountProfileFailure(new Error('no account profile returned')))
return
}
dispatch(loadAccountProfileSuccess(data))
})
.catch(err => dispatch(loadAccountProfileFailure(err)) )
}
}