Advice Generator App || Sass && Fetch API

Please log in to post a comment
Log in with GitHubCommunity feedback
- @a-maystorov
Hi 👋, excellent job on this challenge!
Your question about working with APIs in a more flexible, scalable, and maintainable way depends on the project itself honestly and how many API calls you need to make. I would suggest making a reusable fetchData function or useFetch hook in react, where you pass the URL endpoint as an argument and handle the response inside that function. That way, you can make your API calls anywhere in your project without rewriting the fetch function from scratch. But in this case, where you have only one fetch request, I don't think it's necessary.
I'm not sure if this will help you out, but you can check my solution to the Clock App challenge if you would like a code example. I'm using a reusable fetch function to make calls to three different endpoints. That would give you an idea about maintainability and scalability.
I hope this answers your question; keep on rocking 👊 👩💻 💯.
Marked as helpful
Join our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord