Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New API fetch while sorting data from A-Z upper and lower by name #260

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading