Home react internal axios get request
Reply: 0

react internal axios get request

user842
1#
user842 Published in April 26, 2018, 1:45 pm

I want to call get request and after get data in then block dispatch an action creator that contain another axios get request.

Now, I wrote following code but my get request in fetchCategory action creator is not called!

why?

export const fetchProducts = (uid) => dispatch => {

return axios.get(API.DISPLAY_PRODUCT + uid)
    .then(({ data }) => {

dispatch(setSingleProduct({single: data}))
dispatch(fetchCategory(data.tag))
    }).catch((error) => {   
        console.log(error);
    });
};

export const fetchCategory = (name) => dispatch => {

return axios.get(API.DISPLAY_CATEGORY + name)
    .then(({ data }) => {
        dispatch(setCategory({cat: data}))
    }).catch((error) => {   
        console.log(error);
    });
};
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.336682 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO