Skip to content

Commit

Permalink
chore: add comments in populate
Browse files Browse the repository at this point in the history
  • Loading branch information
felixtanhm committed May 8, 2024
1 parent c6cc6e6 commit 588a41c
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#! /usr/bin/env node
const axios = require("axios");

console.log(
'This script populates some test books, authors, genres and bookinstances to your database. Specified database as argument - e.g.: node populatedb "mongodb+srv://abc:[email protected]/pokemon?retryWrites=true&w=majority"'
);

// Get arguments passed on command line
const userArgs = process.argv.slice(2);

Expand All @@ -29,6 +25,8 @@ async function main() {
"https://pokeapi.co/api/v2/pokemon/?limit=151"
);
let expandList = [];

// Get individual Pokemon Details
if (response.status === 200) {
expandList = await Promise.all(
response.data.results.map(async (item) => {
Expand All @@ -53,6 +51,8 @@ async function main() {
})
);
}

// Create Pokemon and Details for each Pokemon
expandList.forEach(async (item) => {
const { newPokemon, newPokeDetails } = processPokeData(item);
const detailsRef = await createPokeDetails(newPokeDetails);
Expand Down

0 comments on commit 588a41c

Please sign in to comment.