UNPKG

superheros

Version:

Gerenate the names random Super Hero.

82 lines (71 loc) 3.01 kB
// Super Hero API // https://akabab.github.io/superhero-api/api/#powerstats //All Super hero details //https://akabab.github.io/superhero-api/api/glossary.html let ids = [1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 17, 18, 20, 23, 24, 25, 26, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 47, 48, 49, 52, 53, 56, 57, 58, 60, 61, 62, 63, 66, 68, 69, 70, 71, 72, 73, 75, 76, 78, 79, 80, 81, 82, 83, 84, 87, 88, 92, 93, 95, 96, 97, 98, 99, 100, 102, 103, 104, 105, 106, 107, 109, 110, 111, 112, 114, 115, 118, 119, 120, 121, 126, 127, 130, 135, 136, 137, 139, 140, 141, 142, 144, 145, 146, 147, 148, 149, 150, 151, 152, 154, 156, 157, 158, 160, 162, 165, 167, 169, 170, 171, 172, 174, 176, 177, 178, 180, 181, 185, 186, 188, 191, 194, 195, 196, 198, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 224, 225, 226, 227, 228, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 245, 246, 247, 248, 249, 251, 252, 253, 254, 256, 257, 258, 259, 260, 261, 263, 265, 266, 267, 268, 269, 270, 271, 273, 274, 275, 277, 278, 280, 284, 285, 286, 287, 288, 289, 294, 296, 297, 298, 299, 300, 303, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 320, 321, 322, 323, 325, 327, 330, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 360, 361, 364, 365, 367, 369, 370, 371, 372, 373, 374, 375, 376, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 412, 413, 414, 415, 416, 418, 419, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 448, 449, 450, 451, 452, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 467, 469, 470, 471, 472, 474, 475, 476, 477, 478, 479, 480, 481, 483, 484, 485, 487, 488, 489, 490, 491, 492, 493, 495, 496, 497, 498, 499] // -------------------------------------------- (max - min + 1)) + min; let selectRandomId = Math.floor(Math.random() * (382 - 0 + 1)) + 0; console.log(`the length of ids ${ids.length}`) console.log(`The selected random number is ${selectRandomId}`); console.log(`The selected id from random number is ${ids[selectRandomId]}`) function gerenateSuperhero() { let name; fetch(`https://akabab.github.io/superhero-api/api/id/${ids[selectRandomId]}.json`) .then(response => response.json()) .then(data => { console.log(data.name); // console.log(data.images.md) }); } // gerenateSuperhero() module.exports = gerenateSuperhero;