diff --git a/18_Day_Promises/18_day_starter/scripts/main.js b/18_Day_Promises/18_day_starter/scripts/main.js index c6045c8..0f4a57e 100644 --- a/18_Day_Promises/18_day_starter/scripts/main.js +++ b/18_Day_Promises/18_day_starter/scripts/main.js @@ -1,2 +1,10 @@ -console.log(countries) -alert('Open the console and check if the countries has been loaded') \ No newline at end of file +import fetch from "node-fetch"; + +const url = 'https://restcountries.com/v2/all' // countries api +fetch(url) + .then(response => response.json()) // accessing the API data as JSON + .then(data => { + // getting the data + console.log(data) + }) + .catch(error => console.error(error)) // handling error if something wrong happens \ No newline at end of file