pokemon-app-lib v1.0.1
PokeAPI Library
A library to work with the PokeAPI v2.
Browser Support
39+ ✔ | 42+ ✔ | 29+ ✔ | 10.1+ ✔ | IE11+ ✔ |
Dependencies
This library depends on fetch to make requests to the PokeAPI Web API. For environments that don't support fetch, you'll need to provide a polyfill to browser or polyfill to Node.
Installation
$ npm install pokemon-app-lib --save-dev
How to use
// to import a specific method
import { method } from 'pokemon-app-lib';
const [name] = method('[your search]');
// Example:
import { searchByName } from 'pokemon-app-lib';
const squirtleFetch = searchByName('squirtle');
UMD in Browser
<!-- to import non-minified version -->
<script src="pokemon-app-lib.umd.js"></script>
<!-- to import minified version -->
<script src="pokemon-app-lib.umd.min.js"></script>
After that the library will be available to the Global as pokemonAppLib
. Follow an example:
let pokemon = pokemonAppLib.searchByName('charizard');
Methods
Follow the methods that the library provides. You can test all methods in PokeAPI.
searchByName(query)
This method will search your pokemon by the name.
Arguments
Argument | Type | Options |
---|---|---|
query | string or number | 'Any search query' |
Example
pokemonAppLib.searchByName('charizard')
.then(data => {
// do what you want with the data
})
searchByType(query)
This method will search all pokemons from chosen type.
Arguments
Argument | Type | Options |
---|---|---|
query | string or number | 'Any search query' |
Example
pokemonAppLib.searchByType('flying')
.then(data => {
// do what you want with the data
})
searchByAbility(query)
This method will one ability pokemons from one type.
Arguments
Argument | Type | Options |
---|---|---|
query | string or number | 'Any search query' |
Example
pokemonAppLib.searchByAbility(13)
.then(data => {
// do what you want with the data
})
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Authors
Gabriel Santos |
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
Thanks
Special thanks to Willian Justen for that wonderful TDD course!