Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lamba01/rest-countries
This is a Challenge to display countries and their data from Rest API using JavaScript
https://github.com/lamba01/rest-countries
countries-api fetch-api javascript nextjs responsive-design responsive-grid rest-api restful-api
Last synced: about 4 hours ago
JSON representation
This is a Challenge to display countries and their data from Rest API using JavaScript
- Host: GitHub
- URL: https://github.com/lamba01/rest-countries
- Owner: lamba01
- Created: 2023-06-20T13:14:56.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-01T12:49:23.000Z (about 1 year ago)
- Last Synced: 2024-04-17T23:59:24.160Z (7 months ago)
- Topics: countries-api, fetch-api, javascript, nextjs, responsive-design, responsive-grid, rest-api, restful-api
- Language: JavaScript
- Homepage: https://countrysapis.netlify.app/
- Size: 295 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rest-countries
# Frontend Mentor - REST Countries API solutionThis is a solution to the [REST Countries API challenge on Frontend Mentor](https://www.frontendmentor.io/challenges/rest-countries-api-with-color-theme-switcher-5cacc469fec04111f7b848ca). Frontend Mentor challenges help you improve your coding skills by building realistic projects.
## Table of contents
- [Overview](#overview)
- [The challenge](#the-challenge)
- [Screenshot](#screenshot)
- [Links](#links)
- [My process](#my-process)
- [Built with](#built-with)
- [What I learned](#what-i-learned)
- [Continued development](#continued-development)
- [Author](#author)
- [Acknowledgments](#acknowledgments)## Overview
### The challenge
Users should be able to:
- See all countries from the API on the homepage
- Search for a country using an `input` field
- Filter countries by region
- Click on a country to see more detailed information on a separate page
- Click through to the border countries on the detail page### Screenshot
![](./screenshot.png)
### Links
- Solution URL: [https://github.com/lamba01/Rest-countries/]
- Live Site URL: [Add live site URL here](https://your-live-site-url.com)## My process
### Built with
- Semantic HTML5 markup
- CSS custom properties
- Flexbox
- CSS Grid
- JavaScript fetch API### What I learned
Use this section to recap over some of your major learnings while working through this project. Writing these out and providing code samples of areas you want to highlight is a great way to reinforce your own knowledge.
To see how you can add code snippets, see below:
```js
// Fetch the full names of the bordering countries
const borderCountryNames = borderCountries.map((code) => {
const borderCountry = countries.find((c) => c.cca3 === code);
return borderCountry ? borderCountry.name.common : "Unknown Country";
});const borderCountriesElement = document.createElement("p");
if (borderCountryNames.length > 0) {
borderCountriesElement.textContent = "Border Countries:";
} else {
borderCountriesElement.textContent = "No bordering countries.";
}// Assuming you have already calculated the 'borderCountryNames' array
borderCountryNames.forEach((borderCountryName) => {
const borderCountryElement = document.createElement("span");
borderCountryElement.textContent = borderCountryName;
borderCountryElement.classList.add("bordercountries");
borderCountryElement.onclick = () => {
const borderCountryData = getCountryByName(borderCountryName);
displaySingleCountry(borderCountryData);
};
borderCountriesElement.appendChild(borderCountryElement);
borderCountriesElement.classList.add("border");
});
```### Continued development
This is my third project using the fetch API, I think I am finally comfortable with it. I'll move on to learn React now.
## Author
- Frontend Mentor - [@lamba01](https://www.frontendmentor.io/profile/lamba01)
- Twitter - [@lambacodes](https://www.twitter.com/lambacodes)## Acknowledgments
Once again, thank myself for not giving up.