Closed andrewdoro closed 1 year ago
This is mostly about best practices (double nested await calls don't look great). Also I've found this great article about using async/await in useEffect. https://devtrium.com/posts/async-functions-useeffect https://github.com/novuhq/hacksquad-website/blob/ac8591b33959170e63b14bf13fc0b89b31e608f2/src/pages/myteam.jsx#L9-L19
I think changing to this would be much better
useEffect(() => { const getTeam = async () => { const data = await fetch(`/api/team`, { credentials: 'include', }); const json = await data.json(); setInfo(json); }; getTeam(); }, []);
I mean, it's the same thing. If you think that is necessary, go to it!
This is mostly about best practices (double nested await calls don't look great). Also I've found this great article about using async/await in useEffect. https://devtrium.com/posts/async-functions-useeffect https://github.com/novuhq/hacksquad-website/blob/ac8591b33959170e63b14bf13fc0b89b31e608f2/src/pages/myteam.jsx#L9-L19
I think changing to this would be much better