Getting all the “collects” given a collection id using shopify-api-node

Listing_Team
New Member
4 0 0

I need to get all the collects of a given collection.

With the shopify-node-api package (which no longer works for new versions of the api), you could do something like this:

Shopify.get(`/admin/collects.json?collection_id=${id}&limit=250&since_id=${since_id}`

On this page, it shows how you would construct a url to get all the collects for a given collection: GET /admin/api/2021-01/collects.json?collection_id=841564295

How do I use the shopify-api-node package to generate that? I've written this function but it doesn't work:

async _new_getAllCollectsByCollection(id) {
    let params = {collection_id: id};
    let list = [];

    while(params) {
        const collects = await this.newShopify.collect.list(params);
        list = list.concat(collects);
        params = collects.nextPageParameters;
    }

    return list;
}

But when I run the api with those params, I get this: Response code 404 (Not Found)

0 Likes