首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法读取未定义的属性(读取“loadCurrentSession”)

无法读取未定义的属性(读取“loadCurrentSession”)
EN

Stack Overflow用户
提问于 2022-04-17 23:53:42
回答 1查看 1.2K关注 0票数 2

我使用shopify api,为什么我会收到以下错误消息:

代码语言:javascript
复制
Cannot read properties of undefined (reading 'loadCurrentSession')
代码语言:javascript
复制
 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
  })
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-04-23 11:59:00

首先在根server.js文件中定义此函数

代码语言:javascript
复制
 export default async function returnSessionData(req, res) {
  const decode =  await Shopify.Utils?.loadCurrentSession(req, res);
  return decode
}

并从您的路由控制器调用这个returnSessionData(req,res)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71906347

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档