score:0


const handleError = (error) => {
   console.log(error);
};

export const getUserData = (userData) => {
    return axios
        .get("/api/users/userdata", userData)
        .then(response => (response.data))
        .catch(err => {
            handleError(err);
        });
};

...
// later in thunk action creator 

const updateUserDataThunk = async (userData) => dispatch => {
    const apiData = await getUserData(userData);
    dispatch(updateUser(apiData));
}

...
// in component

componentDidMount(){
  dispatch(updateUserDataThunk(this.props.userData));
}


Related Query

More Query from same tag