Skip to content

Commit

Permalink
Merge pull request #260 from ChristianBDev/main
Browse files Browse the repository at this point in the history
New API fetch while sorting data from A-Z upper and lower by name
  • Loading branch information
GhzGarage authored Dec 23, 2024
2 parents f2fb43e + 4802250 commit 2126324
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -454,4 +452,4 @@

});
</script>
</html>
</html>

0 comments on commit 2126324

Please sign in to comment.