-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (38 loc) · 1.32 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
const pokemonService = require("./src/pokemonService");
const pokemonServiceObj = new pokemonService();
function askId() {
console.log("Escribe el id del Pokemon");
var id = process.openStdin();
try {
id.addListener("data", async function (d) {
d = d.toString().trim();
id = parseInt(d, 10);
//console.log(id);
if (Number.isInteger(id)) {
const pokemon = await pokemonServiceObj.getPokemon(id);
if (pokemon.name != undefined) {
console.log("Pokemon Name:" + pokemon.name);
console.log("Pokemon Height: " + pokemon.height + " kls");
console.log("Pokemon Weight: " + pokemon.weight + " cms");
console.log("Pokemon Id: " + pokemon.id);
console.log("Pokemon Stats: " + pokemon.stats);
const evolutions = await pokemonServiceObj.getEvolutions(id);
console.log("Pokemon Evolutions: " + evolutions);
console.log(
"Fin del servicio, para otra consulta sube de vuelta el servicio con el comando <node index.js>"
);
process.exit(1);
} else {
console.log("Id no existe");
process.exit(1);
}
} else {
console.log("Digite un Id valido");
process.exit(1);
}
});
} catch (error) {
console.log("Error: " + error);
}
}
askId();