Sample code for 30+ languages & platforms
Node.js

Shopify Receive Count of All Products in a Collection

See more Shopify Examples

Get a count of all products of a given collection

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

    var rest = new chilkat.Rest();

    rest.SetAuthBasic("SHOPIFY_PRIVATE_API_KEY","SHOPIFY_PRIVATE_API_KEY");

    success = rest.Connect("chilkat.myshopify.com",443,true,true);
    if (success !== true) {
        console.log(rest.LastErrorText);
        return;
    }

    var sbJson = new chilkat.StringBuilder();
    success = rest.FullRequestNoBodySb("GET","/admin/products/count.json?collection_id=841564295 ",sbJson);
    if (success !== true) {
        console.log(rest.LastErrorText);
        return;
    }

    if (rest.ResponseStatusCode !== 200) {
        console.log("Received error response code: " + rest.ResponseStatusCode);
        console.log("Response body:");
        console.log(sbJson.GetAsString());
        return;
    }

    var json = new chilkat.JsonObject();
    json.LoadSb(sbJson);

    // The following code parses the JSON response.
    // A sample JSON response is shown below the sample code.
    var count;

    count = json.IntOf("count");

    // A sample JSON response body that is parsed by the above code:

    // {
    //   "count": 1
    // }

    console.log("Example Completed.");

}

chilkatExample();