create-react-app-redux icon indicating copy to clipboard operation
create-react-app-redux copied to clipboard

Dispatch with Axios doesn't work

Open tarim opened this issue 5 years ago • 2 comments

Hi There,

I am using your app, and I have an issue for HTTP request with the axios. I don't know why it doesn't work. I used it before with my other applications. Can you help me, please?

Here is some code export function getUsers() { return function (dispatch) { dispatch(Action.startLoadingSuccess()); GET(/api/v1/accounts/user`).then(response => { if(response && response.data) dispatch(Action.getUserSuccess(response)); }).catch(err => { console.log('error is: ', err); if (err.response && err.response.data) toastr.error('', err.response.data.message, toastrOption); else {if(err.message) toastr.error('', err.message, toastrOption);} }); };

}`

tarim avatar Sep 26 '18 15:09 tarim

Hi.

I have tried to use axios on my project, too. export const search = (value) => { return dispatch => { axios.get('https://data.buyingazhomes.com/ownership/fuzzy/?query=13 E Coronado 85006') .then(response => { console.log(response.data) })

dispatch({
  type: SEARCH
})

} }

But I got CORS error. Is there any solution to use axios in this project?

albertbarbosa avatar Jan 23 '19 21:01 albertbarbosa

@albertbarbosa you can refer this #71, added an Axios support for a get request.

vipinlahoti avatar Jan 26 '19 17:01 vipinlahoti