create-react-app-redux
create-react-app-redux copied to clipboard
Dispatch with Axios doesn't work
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);}
});
};
}`
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 you can refer this #71, added an Axios support for a get request.