File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727 < section class ="contributors-container "> </ section >
2828 </ main >
2929 </ div >
30+ < script src ="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js "> </ script >
3031 < script src ="index.js "> </ script >
3132 </ body >
3233</ html >
Original file line number Diff line number Diff line change 11'use strict' ;
22
33{
4- function fetchJSON ( url , cb ) {
5- fetch ( url )
6- . then ( ( response ) => {
7- if ( ! response . ok ) {
8- throw new Error (
9- `Network error: ${ response . status } - ${ response . statusText } ` ,
10- ) ;
11- }
12- return response . json ( ) ;
13- } )
14- . then ( ( data ) => cb ( null , data ) )
15- . catch ( ( error ) => cb ( error , null ) ) ;
4+ async function fetchJSON ( url , cb ) {
5+ try {
6+ const response = await axios . get ( url )
7+ const data = response . data
8+ cb ( null , data )
9+ } catch ( error ) {
10+ cb ( error , null )
11+ }
1612 }
1713
1814 function createAndAppend ( name , parent , options = { } ) {
You can’t perform that action at this time.
0 commit comments