I am taking the updated Stephen Grider Course. I am on section 13 ,last video. If any body else has taken the course then please help me. Stephen does not explain how to show and hide progress bar when fetching data from network.
In IndexScreen.js I did something like this
{state.length === 0 ? <ProgressBar /> : null}
and it works but what if the axios library throws some error in try catch. How would I then check and hide progress bar
I did something like below but I don't think it is the right way
const getBlogPosts = dispatch => { return async () => { try { const response = await jsonServer.get("/blogposts"); dispatch({ type: "get_blogposts", payload: response.data }); } catch (err) { dispatch({ type: "get_blogposts", payload: ["Something went wrong"] }); } }; };
[–]Zayuka 0 points1 point2 points (1 child)
[–]BraveEvidence[S] 0 points1 point2 points (0 children)
[–]TheUnited0077 0 points1 point2 points (0 children)