我正在尝试使用这个名为 shopify-node-api 的 npm 包制作一个 NodeJS 应用程序
请注意,这是在 Shopify 合作伙伴帐户中生成的私有(private)应用。我已经按照文档的指示传递了 shopName
、apiKey
和 password
。
const Shopify = require('shopify-api-node');
const shopify = new Shopify({
shopName: 'your-shop-name',
apiKey: 'your-api-key',
password: 'your-app-password'
});
但是,当尝试执行像此 GET 这样简单的操作时:
shopify.product.get()
.then(products => res.send(products))
.catch(err => res.send(err));
我收到:
{
"name": "HTTPError",
"hostname": "your-shop-name",
"method": "GET",
"path": "/admin/products.json",
"protocol": "https:",
"statusCode": 401,
"statusMessage": "Unauthorized",
"headers": {...}
}
对于所有 Shopify 应用程序/JavaScript 专家,请告知我忽略了什么?
最佳答案
归根结底,我在这里的错误是使用这些绑定(bind)错误地使用了 API 调用。
代替:
shopify.product.get()
.then(products => res.send(products))
.catch(err => res.send(err));
我应该一直在用这个:
shopify.product.list()
.then(products => res.send(products))
.catch(err => res.send(err));
关于javascript - shopify-api-node 返回状态 401 未授权私有(private)应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54777027/