From 4802250b90ae855d6a9b43f0db13471958c72f17 Mon Sep 17 00:00:00 2001 From: Christian J Bennett <58433059+ChristianBDev@users.noreply.github.com> Date: Sun, 22 Dec 2024 19:57:43 -0600 Subject: [PATCH] New API fetch while sorting data from A-Z upper and lower by name --- html/index.html | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/html/index.html b/html/index.html index 15583e8..37b6ab6 100644 --- a/html/index.html +++ b/html/index.html @@ -273,16 +273,14 @@ }, methods: { async fetchData() { - const response = await fetch('https://countriesnow.space/api/v0.1/countries/'); - if(response){ + const response = await fetch("https://api.sampleapis.com/countries/countries"); + + if (response.ok) { const data = await response.json(); - const result = data.data; + const countryNames = data.map((country) => country.name); + const result = countryNames.sort((a, b) => a.localeCompare(b)); - const selectDrop = document.getElementById('nationality'); - - result.forEach(obj => { - viewmodel.nationalities.push(obj.country); - }); + this.nationalities = result; } }, click_character: function(idx, type) { @@ -454,4 +452,4 @@ }); - \ No newline at end of file +