-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
57 lines (44 loc) · 1.3 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var rp = require('request-promise');
var pokeUrl = 'http://pokeapi.co';
getJSON = function(url) {
var options = {
url: url,
json: true,
};
return rp.get(options)
.catch(function(error) {
return error;
})
.then(function(response) {
return response;
});
};
var Pokedex = (function() {
function Pokedex() {}
Pokedex.prototype.getPokemonList = function() {
return getJSON(pokeUrl + '/api/v1/pokedex/1/');
};
Pokedex.prototype.getPokemonById = function(id) {
return getJSON(pokeUrl + '/api/v1/pokemon/' + id + '/');
};
Pokedex.prototype.getTypeById = function(id) {
return getJSON(pokeUrl + '/api/v1/type/' + id + '/');
};
Pokedex.prototype.getMoveById = function(id) {
return getJSON(pokeUrl + '/api/v1/move/' + id + '/');
};
Pokedex.prototype.getAbilityById = function(id) {
return getJSON(pokeUrl + '/api/v1/ability/' + id + '/');
};
Pokedex.prototype.getEggById = function(id) {
return getJSON(pokeUrl + '/api/v1/egg/' + id + '/');
};
Pokedex.prototype.getDescriptionById = function(id) {
return getJSON(pokeUrl + '/api/v1/description/' + id + '/');
};
Pokedex.prototype.getSpriteById = function(id) {
return getJSON(pokeUrl + '/api/v1/sprite/' + id + '/');
};
return Pokedex;
})();
module.exports = Pokedex;