Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

how to use the pokeapi in 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 :: The velocity of light in vacuum is 
Typescript :: useappdispatch 
Typescript :: store all years in array angular 
Typescript :: stipe elements angular.js 
Typescript :: welsh cup electrodes have 
Typescript :: angular services status return 400 response 
Typescript :: saving leaderstats script roblox 
Typescript :: elastice search requirements in ubunt 
Typescript :: get-dirstats not recognized 
Typescript :: How to join all url segments to make a url in javascipt 30seconds of code 
Typescript :: requestRandomness 3 arguments given but expected 2 
Typescript :: More than one custom value accessor matches form control with unspecified name attribute 
Typescript :: how to import contacts from android phone to laptop 
Typescript :: how to add every two elements in python 
Typescript :: stats normal 
Typescript :: which network device reads the source and destination MAC addresses, looks up the destination to determine where to send the frame, and forwards it out to the correct port 
Typescript :: nativescript date input validation 
Typescript :: react native websocket disconnect handler 
Typescript :: vba check if two sheets are the same 
Typescript :: What will be the result of the cp /etc/hosts . command? 
Typescript :: how many bits are there in a hexadecimal digit 
Typescript :: nest js config from yaml 
Typescript :: rstudio plots arrows(), text() 
Typescript :: Fragment no longer exists 
Typescript :: let variable name : any = () = { return new typescript fie} 
Typescript :: for loop of unlimited inputs python 
Typescript :: difference known_hosts authorized_keys 
Typescript :: HOW TO DROP ALL TABLES WITH THEIR CONSTRAINTS AT ONCE IN ORACLE 
Typescript :: pdfunite all documents in a folder with alphabetical order 
Typescript :: typescript cast to type remove properties 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =