Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

how to use the pokeapi with javascript

// npm install pokedex-promise-v2 --save

import Pokedex from 'pokedex-promise-v2';
const P = new Pokedex();

(async () => { // with Async/Await
    try {
        const golduckSpecies = await P.getPokemonSpeciesByName("golduck")
        const frenchName = golduckSpecies.names.filter(pokeAPIName => pokeAPIName.language.name === 'fr')[0].name
        console.log(frenchName)
    } catch (error) {
        throw error
    }
})()

P.getPokemonByName(['eevee', 'ditto']) // with Promise
  .then((response) => {
    console.log(response);
  })
  .catch((error) => {
    console.log('There was an ERROR: ', error);
  });

P.getPokemonByName(34, (response, error) => { // with callback
    if(!error) {
      console.log(response);
    } else {
      console.log(error)
    }
  });

P.getResource(['/api/v2/pokemon/36', 'api/v2/berry/8', 'https://pokeapi.co/api/v2/ability/9/'])
  .then((response) => {
    console.log(response); // the getResource function accepts singles or arrays of URLs/paths
  });
Comment

PREVIOUS NEXT
Code Example
Typescript :: Do feral cats have rabies? 
Typescript :: flutter allow user to select text 
Typescript :: haproxy stats config 
Typescript :: number of increments and decrements to make array sorted 
Typescript :: my controller is not recognized and it actually exists why is this happening 
Typescript :: how to assert element attributes in mocha js 
Typescript :: typescript react display array 
Typescript :: woocommerce remove This is where you can add new products to your store in taxonomy description 
Typescript :: what do you expect from us 
Typescript :: react cra ts custom outputdir 
Typescript :: Event Handing With Vue 
Typescript :: Defects and Defect Density of quality software 
Typescript :: Named types just give a name to a type 
Typescript :: how to update firebase document field angular 
Typescript :: typescript / javascript merge sorted arrays 
Typescript :: expected assets to be a list in flutter 
Typescript :: python arbitrary arguments *args mcqs 
Typescript :: how to get all the points of the circufrence python 
Typescript :: keep footer after all elements react 
Typescript :: can check constraints reference other tables 
Typescript :: aws elastic web python stops ajax requests if new request is made 
Typescript :: how to append different lists in installed apps django 
Typescript :: Return first k terms from vector 
Typescript :: ts Template pattern 
Typescript :: flutter create widget for each element of list 
Typescript :: how to remove dots in unordered list html 
Typescript :: selenium components 
Typescript :: whats the internet 
Typescript :: list all motherboard ports command line 
Cpp :: fast input output cpp 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =