MONEI / Shopify-api-node

Node Shopify connector sponsored by MONEI
https://monei.com/shopify-payment-gateway/
MIT License
940 stars 279 forks source link

Can't use await #570

Closed lacabra-dev closed 1 year ago

lacabra-dev commented 1 year ago

Hi everyone

why can I do the following

shopifyStore.product .get(product.id) .then((result) => { console.log(result); }) .catch((error) => { console.error(error); });

But I cannot do this: const result = await shopifyStore.product.get(product.id); ? I get

node_modules/got/dist/source/as-promise/index.js:118 request._beforeError(new types_1.HTTPError(response)); ^ HTTPError: Response code 404 (Not Found)

lpinca commented 1 year ago

I can't reproduce.

$ cat index.mjs
import Shopify from 'shopify-api-node';

const shopify = new Shopify({
  shopName: 'quuz',
  apiVersion: '2023-01',
  apiKey: 'b68c3a4bf44cd240511e5f4114f0be4d',
  password: '2d170167fc62551920ca60fe40a5e548'
});

const products = await shopify.product.list();

console.log(products);
$ node index.mjs
[]
lpinca commented 1 year ago

Are you sure that product.id in your example matches an existing product?

lacabra-dev commented 1 year ago

Thanks for the prompt response ! :)

What if it doesnt? I'll check shortly, but I mean if I query for a product and it cant find it, I'd expect the return to be an empty array just like the .list(), why would it be a 404?

lpinca commented 1 year ago

why would it be a 404?

Because 404 is what the API returns for something that does not exist. That is APIs standard behavior.

lpinca commented 1 year ago

I'm closing this as answered.