Skip to content

Instantly share code, notes, and snippets.

Last active August 16, 2022 08:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Promise Pool Showcase
// Think that we got the list of products to import into database(May be from CSV or external API anything...)
const { products } = require("./products");
async function execute() {
let importedProducts = [];
for await (const data of products) {
const product = await importProduct(data);
async function importProduct(data) {
// Code to import product into database
// Imagine createProduct function creates product into the database and returns the database product instance
return createProduct(data);
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment