-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
31 lines (31 loc) · 1.01 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
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPokemonTypeById = exports.getPokemonById = void 0;
const axios_1 = __importDefault(require("axios"));
const API_URL = 'https://pokeapi.co/api/v2';
function getPokemonById(id) {
return new Promise((resolve, reject) => {
axios_1.default
.get(`${API_URL}/pokemon/${id}`)
.then((resp) => {
resolve(resp.data);
})
.catch(reject);
});
}
exports.getPokemonById = getPokemonById;
function getPokemonTypeById(id) {
return new Promise((resolve, reject) => {
axios_1.default
.get(`${API_URL}/type/${id}`)
.then((resp) => {
resolve(resp.data);
})
.catch(reject);
});
}
exports.getPokemonTypeById = getPokemonTypeById;
exports.default = { getPokemonById, getPokemonTypeById };