Skip to content

Commit ea4b8c9

Browse files
authored
Merge pull request #262 from ChristianBDev/main
Added another api for now
2 parents 2126324 + 48b8e63 commit ea4b8c9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

html/index.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,14 @@
273273
},
274274
methods: {
275275
async fetchData() {
276-
const response = await fetch("https://api.sampleapis.com/countries/countries");
277-
276+
const response = await fetch("https://restcountries.com/v3.1/all");
278277
if (response.ok) {
279-
const data = await response.json();
280-
const countryNames = data.map((country) => country.name);
281-
const result = countryNames.sort((a, b) => a.localeCompare(b));
278+
const countries = await response.json();
279+
const result = countries.sort((a, b) => (a.name.common > b.name.common ? 1 : -1));
282280

283-
this.nationalities = result;
281+
result.forEach((obj) => {
282+
viewmodel.nationalities.push(obj.name.common);
283+
});
284284
}
285285
},
286286
click_character: function(idx, type) {

0 commit comments

Comments
 (0)