File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change 273
273
} ,
274
274
methods : {
275
275
async fetchData ( ) {
276
- const response = await fetch ( 'https://countriesnow.space/api/v0.1/countries/' ) ;
277
- if ( response ) {
276
+ const response = await fetch ( "https://api.sampleapis.com/countries/countries" ) ;
277
+
278
+ if ( response . ok ) {
278
279
const data = await response . json ( ) ;
279
- const result = data . data ;
280
+ const countryNames = data . map ( ( country ) => country . name ) ;
281
+ const result = countryNames . sort ( ( a , b ) => a . localeCompare ( b ) ) ;
280
282
281
- const selectDrop = document . getElementById ( 'nationality' ) ;
282
-
283
- result . forEach ( obj => {
284
- viewmodel . nationalities . push ( obj . country ) ;
285
- } ) ;
283
+ this . nationalities = result ;
286
284
}
287
285
} ,
288
286
click_character : function ( idx , type ) {
454
452
455
453
} ) ;
456
454
</ script >
457
- </ html >
455
+ </ html >
You can’t perform that action at this time.
0 commit comments