Skip to content

Making REST API calls with a Cli generated app #1121

Answered by fonya2014
SaiSa22 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @SaiSa22 ! You need to make changes in index.js on line 104:

app.get("/api/products/count", async (req, res) => {
    const session = await Shopify.Utils.loadCurrentSession(
      req,
      res,
      app.get("use-online-tokens")
    );
    /*const { Product } = await import(
      `@shopify/shopify-api/dist/rest-resources/${Shopify.Context.API_VERSION}/index.js`
    );*/

    const { Customer } = await import(
      `@shopify/shopify-api/dist/rest-resources/${Shopify.Context.API_VERSION}/index.js`
    );

    const countData = await Customer.count({ session });
    res.status(200).send(countData);
  });

You need to replace Product with Customer.

You don't need to change the URL in …

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@SaiSa22
Comment options

Comment options

You must be logged in to vote
1 reply
@SaiSa22
Comment options

Comment options

You must be logged in to vote
2 replies
@SaiSa22
Comment options

@fonya2014
Comment options

Answer selected by SaiSa22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants