Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish 4.0.0 #54

Merged
merged 5 commits into from
Nov 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
- name: Build
run: |
npm run generate:types
npm run generate:jsdocs
npm run generate:main
npm run generate:jsdocs
- name: Unit test
run: |
npm t
Expand Down
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

67 changes: 47 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pokedex-promise-v2 <a href="https://pokeapi.co/api/v2/pokemon/bulbasaur"><img src='https://veekun.com/dex/media/pokemon/global-link/1.png' height=50px/></a>

[![npm version](https://badge.fury.io/js/pokedex-promise-v2.svg)](https://badge.fury.io/js/pokedex-promise-v2)
[![Build Status](https://travis-ci.org/PokeAPI/pokedex-promise-v2.svg?branch=master)](https://travis-ci.org/PokeAPI/pokedex-promise-v2)
[![Tests](https://github.com/PokeAPI/pokedex-promise-v2/actions/workflows/test.yml/badge.svg)](https://github.com/PokeAPI/pokedex-promise-v2/actions/workflows/test.yml)
[![Package Quality](http://npm.packagequality.com/shield/pokedex-promise-v2.svg)](http://packagequality.com/#?package=pokedex-promise-v2)
[![npm](https://img.shields.io/npm/l/express.svg?maxAge=2592000)](https://github.com/PokeAPI/pokedex-promise-v2/blob/master/LICENSE)

Expand Down Expand Up @@ -38,6 +38,8 @@ An easy way to use [Pokéapi](https://pokeapi.co/) v2 with promises *(or callbac

## Install [![nodeVersion](https://img.shields.io/badge/node->=12-brightgreen.svg)](https://www.npmjs.com/package/pokedex-promise-v2)

> As of 4.0.0 this package is now pure ESM. Please [read this](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).

```sh
npm install pokedex-promise-v2 --save
```
Expand All @@ -61,29 +63,39 @@ const P = new Pokedex();

**UPDATE**: You can pass an array to each endpoint, it will retrive data for each array element. If you scroll down, you will find an example.

### [Example](./test/test_async.js) requests
### Example requests

```js
P.getPokemonByName('eevee') // with Promise
.then((response) => {
console.log(response);
})
.catch((error) => {
console.log('There was an ERROR: ', error);
});
(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(34, (response, error) => { // with callback
if(!error) {
console.log(response);
} else {
console.log(error)
}
});
P.getPokemonByName(['eevee', 'ditto']) // with Promise
.then((response) => {
console.log(response);
})
.catch((error) => {
console.log('There was an ERROR: ', 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
});
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
});
```

## Configuration
Expand Down Expand Up @@ -782,3 +794,18 @@ This is what you will get:
* .getStatsList()
* .getTypesList()
* .getLanguagesList()

## Development

A linux environment is preferred. `bash`, `sed`, `find` and required.

```sh
npm i
npm run apidata:clone # Only if you are building for the first time
npm run apidata:sync # Only if you have already built once
npm run apidata:replace
npm run generate:types
npm run generate:main
npm run generate:jsdocs
npm t
```
Loading