无法读取未定义的属性(读取 'loadCurrentSession')
Cannot read properties of undefined (reading 'loadCurrentSession')
我使用 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
})
首先在你的根 server.js 文件中定义这个函数
export default async function returnSessionData(req, res) {
const decode = await Shopify.Utils?.loadCurrentSession(req, res);
return decode
}
然后从您的 route-controller
调用此 returnSessionData(req, res)
我使用 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
})
首先在你的根 server.js 文件中定义这个函数
export default async function returnSessionData(req, res) {
const decode = await Shopify.Utils?.loadCurrentSession(req, res);
return decode
}
然后从您的 route-controller
调用此 returnSessionData(req, res)