【发布时间】:2021-04-19 11:13:32
【问题描述】:
在我的 server.js 文件中,我在 afterAuth 函数中注册了应用程序/卸载的 webhook,如下所示:
const response = await Shopify.Webhooks.Registry.register({
shop,
accessToken,
path: "/webhooks",
topic: "APP_UNINSTALLED",
apiVersion: ApiVersion.October20,
webhookHandler: (topic, shop, body) => {
//console.log(topic, shop,body);
delete ACTIVE_SHOPIFY_SHOPS[shop];
},
});
我正在听这样的路线
router.post("/webhooks", appUninstallWebhook, async (ctx) => {
try {
await Shopify.Webhooks.Registry.process(ctx.req, ctx.res);
console.log(`Webhook processed, returned status code 200`);
} catch (error) {
console.log(`Failed to process webhook: ${error}`);
}
});
我看到 webhook 已成功注册,但是当我在我的测试 Shopify 商店中删除在 ngrok 上本地运行的应用程序时,我没有看到该 webhook 被触发。
任何帮助都会非常有帮助。
【问题讨论】:
-
你好,伙计!你过了这一关吗?我被困在完全相同的事情上
-
@DanTurner 不。您可以使用这种方法。这有效 const response = await registerWebhook({ shop, accessToken, address:
${HOST}/webhooks/app/uninstalled, topic: "APP_UNINSTALLED", apiVersion: API_VERSION });然后配置路由 router.post("/webhooks/app/uninstalled", webhook, async (ctx) => { try { console.log(Webhook processed, returned status code 200); } catch (error) { console.log(@987654325 @); } });
标签: node.js reactjs shopify webhooks