Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 1 year ago

Rest countries API with theme toggle in vanilla JavaScript

Ridwan Al Mahmud•100
@ridwanalmahmud
A solution to the REST Countries API with color theme switcher challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


What are you most proud of, and what would you do differently next time?

I used a simple approach towards the projects and used vanilla JavaScript for the whole project. It added much more knowledge about JavaScript params, history api, localstorage, URI Component, asynchronous functions and much more.I added theme toggle, search functionality, sorting the feed by region and pagination 20 countries data per page. And all of them are stored in localstorage so that after I visit my details page or I refresh the page the theme or the selected region doesn't get changed.

What challenges did you encounter, and how did you overcome them?

While, I was working with fetching the data in my details page I noticed that some of the countries weren't showing the data.At first,I thought that it's because of the space between some country's name but also some countries like Antarctica wasn't showing the data. The real reason was that I was trying to fetch the borders and currencies of the countries while some countries didn't have currencies or borders like Antarctica doesn't have a currency and American Samoa doesn't have borders.So,I added a ternary operator to handle the cases where there aren't any currency or borders.

And after I added pagination I found that when I move to the next page the selection and the search gets refreshed so I added that to localstorage so that doesn't get refreshed.

Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

No feedback yet. Be the first to give feedback on Ridwan Al Mahmud's solution.

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

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner
  • Use cases

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License