
Rest Countries Api using React.js
Design comparison
Solution retrospective
Being able to fetch my api url using const restUrl = "url-address". What i'd do differently is to not just fetch the url while await async but also include a try and catch function to be exact
What challenges did you encounter, and how did you overcome them?Trying to figure out the all countries card section. it wasn't displaying all of it until i flex items-columns and also the media responsiveness for different screen sizes. had to us the md, lg and sm style property to debug that with my tailwind css
What specific areas of your project would you like help with?i personally think i can help with all areas of this projects as it took me 3 days to successfully program it.
Community feedback
- @ippotheboxerPosted about 1 month ago
Hi, what you've done so far is really great! The search works and the filter by region. However you didn't incorporate one of the keys parts of the app, which was clicking on a country article to get more specific information displayed. Here is some advice on how to implement it: In your App.jsx, you aren't using BrowserRouter to get dynamic routing, so currently it would be impossible to implement this other page. In the App.jsx, you could make it look like this:
return ( <div className="min-h-screen"> <BrowserRouter> <Routes> <Route path='/' element={<Home />} /> <Route path='/home' element={<Home /> } /> <Route path='/:countryName' element={<SpecificCountry />} /> </Routes> </BrowserRouter> </div>
And then create a Home.jsx in a pages folder. Then simply move the code you currently have in App.jsx to Home.jsx. Now when you are mapping through in AllCountries.jsx, wrap it with
<Link to={`${country.name.common}`}> </Link>
. Now you can create a new page called SpecificCountry.jsx and include all the more specific information. Now on that page useconst { countryName } = useParams();
to get the countryName from the link. You can make a get request to the api with that name now, and get all the specific information. Then you can include a back button on it withconst navigate = useNavigate(); ... <button onClick={() => navigate("/")}>Back</button>
To go back to the homepage. Hope this helps!
0
Please log in to post a comment
Log in with GitHubJoin 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