import fetch from "node-fetch" ; interface PokemonResults { count : number ; next ? : string ; previous ? : string ; results : { name : string ; url : string ; } [ ] ; } function fetchPokemon ( url , cb ) ; function fetchPokemon ( url ) ; function fetchPokemon ( url , cb ? ) { if ( cb ) { fetch ( url ) . then ( ( data ) => data . json ( ) ) . then ( ( data ) => cb ( data ) ) ; return ; } else { return fetch ( url ) . then ( ( data ) => data . json ( ) ) ; } } fetchPokemon ( "https://pokeapi.co/api/v2/pokemon?limit=10" , ( data ) => { data . results . forEach ( ( { name } ) => console . log ( name ) ) ; } ) ; ( async function ( ) { const data = await fetchPokemon ( "https://pokeapi.co/api/v2/pokemon?limit=10" ) ; data . results . forEach ( ( { name } ) => console . log ( name ) ) ; } ) ( ) ;