我使用shopify api,为什么我会收到以下错误消息:
Cannot read properties of undefined (reading 'loadCurrentSession') const Shopify = require('@shopify/shopify-api');
const { Product } = require('@shopify/shopify-api/dist/rest-resources/2022-04/index.js');
// Initializing a client to return content in the store's primary language
const test_session = await Shopify.Utils.loadCurrentSession(request, response);
const d = await Product.all({
session: test_session
})发布于 2022-04-23 11:59:00
首先在根server.js文件中定义此函数
export default async function returnSessionData(req, res) {
const decode = await Shopify.Utils?.loadCurrentSession(req, res);
return decode
}并从您的路由控制器调用这个returnSessionData(req,res)。
https://stackoverflow.com/questions/71906347
复制相似问题