Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ async function exportCSV(data) {
return await parser.parse(data).promise();
}

const listingURL = "https://warehouse-theme-metal.myshopify.com/collections/sales"
const listingURL = "https://warehouse-theme-metal.myshopify.com/collections/sales";
const $ = await download(listingURL);

const $items = $(".product-item").map((i, element) => {
Expand Down Expand Up @@ -283,7 +283,7 @@ function parseProduct($productItem, baseURL) {
Now we'll pass the base URL to the function in the main body of our program:

```js
const listingURL = "https://warehouse-theme-metal.myshopify.com/collections/sales"
const listingURL = "https://warehouse-theme-metal.myshopify.com/collections/sales";
const $ = await download(listingURL);

const $items = $(".product-item").map((i, element) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async function exportCSV(data) {
return await parser.parse(data).promise();
}

const listingURL = "https://warehouse-theme-metal.myshopify.com/collections/sales"
const listingURL = "https://warehouse-theme-metal.myshopify.com/collections/sales";
const $ = await download(listingURL);

const $items = $(".product-item").map((i, element) => {
Expand Down Expand Up @@ -134,7 +134,7 @@ In the `.map()` loop, we're already going through all the products. Let's expand
First, we need to make the loop asynchronous so that we can use `await download()` for each product. We'll add the `async` keyword to the inner function and rename the collection to `$promises`, since it will now store promises that resolve to items rather than the items themselves. We'll still convert the collection to a standard JavaScript array, but this time we'll pass it to `await Promise.all()` to resolve all the promises and retrieve the actual items.

```js
const listingURL = "https://warehouse-theme-metal.myshopify.com/collections/sales"
const listingURL = "https://warehouse-theme-metal.myshopify.com/collections/sales";
const $ = await download(listingURL);

// highlight-next-line
Expand All @@ -150,7 +150,7 @@ const data = await Promise.all($promises.get());
The program behaves the same as before, but now the code is prepared to make HTTP requests from within the inner function. Let's do it:

```js
const listingURL = "https://warehouse-theme-metal.myshopify.com/collections/sales"
const listingURL = "https://warehouse-theme-metal.myshopify.com/collections/sales";
const $ = await download(listingURL);

const $promises = $(".product-item").map(async (i, element) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ We loop over the variants using Cheerio's `.map()` method to create a collection
Let's adjust the loop so it returns a promise that resolves to an array of items instead of a single item. If a product has no variants, we'll return an array with a single item, setting `variantName` to `null`:

```js
const listingURL = "https://warehouse-theme-metal.myshopify.com/collections/sales"
const listingURL = "https://warehouse-theme-metal.myshopify.com/collections/sales";
const $ = await download(listingURL);

const $promises = $(".product-item").map(async (i, element) => {
Expand Down Expand Up @@ -285,7 +285,7 @@ function parseVariant($option) {
}
// highlight-end

const listingURL = "https://warehouse-theme-metal.myshopify.com/collections/sales"
const listingURL = "https://warehouse-theme-metal.myshopify.com/collections/sales";
const $ = await download(listingURL);

const $promises = $(".product-item").map(async (i, element) => {
Expand Down
Loading