【发布时间】:2018-05-11 14:54:19
【问题描述】:
我的 Shopify Admin API 无法在 Google 托管服务器上运行,但可以在 localhost 上运行。我想知道我错过了什么。
我在本地主机上获得了我的订单数据,但是当我将代码上传到谷歌服务器时它不起作用。
我正在为我的商店开发一个私人应用程序。
没有运气尝试使它起作用。
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
const Shopify = require('shopify-api-node');
const shopify = new Shopify({
shopName: 'tinyrabbithole',
apiKey: 'your-api-key',
password: 'your-app-password'
// accessToken: ""
});
shopify.on('callLimits', limits => console.log(limits));
// Take the text parameter passed to this HTTP endpoint and insert it into the
// Realtime Database under the path /messages/:pushId/original
exports.getData = functions.https.onRequest((req, res) => {
shopify.order.list({ limit: 5 })
.then( orders => {
console.log(orders);
return res.status(200).send(orders);
})
.catch( err => {
console.log(err);
return res.status(303).send(err);
})
});
{ RequestError: getaddrinfo ENOTFOUND tinyrabbithole.myshopify.com tinyrabbithole.myshopify.com:443
at ClientRequest.req.once.err (/user_code/node_modules/shopify-api-node/node_modules/got/index.js:182:22)
at ClientRequest.g (events.js:292:16)
at emitOne (events.js:101:20)
at ClientRequest.emit (events.js:188:7)
at TLSSocket.socketErrorListener (_http_client.js:310:9)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:188:7)
at connectErrorNT (net.js:1025:8)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
name: 'RequestError',
code: 'ENOTFOUND',
host: undefined,
hostname: 'tinyrabbithole.myshopify.com',
method: 'GET',
path: '/admin/orders.json?limit=5',
protocol: 'https:',
url: undefined }
【问题讨论】:
-
Cloud Functions 日志中出现什么错误?
-
更新了错误。 @RenaudTarnec
-
显然您的 shopify 端点有问题。您的代码中的第 nbr 182 行是什么?
-
我找不到那行。不确定当它上传到firebase时,文件是否发生了变化。我发现的唯一 index.js 文件在 shopify-api-node 中只有 156 行。我正在使用这个github.com/MONEI/Shopify-api-node/blob/master/index.js@RenaudTarnec
-
您的计划是否正确?您无法在免费层上进行传出 API 调用。
标签: javascript firebase shopify google-cloud-functions shopify-app