const sessionCopy = new Session(sessionData); // Pulled from database.
// TODO: Getting error: TypeError: Cannot read properties of undefined (reading 'accessToken')
// at (/node_modules/@shopify/shopify-api/dist/cjs/lib/clients/admin/rest/client.js:27:50)
const restClient = new shopify.clients.Rest({sessionCopy});
Here’s the sessionData object:
{
shop: 'X.myshopify.com',
scope: 'read_orders',
isOnline: false,
id: 'offline_X.myshopify.com',
state: '358222388575483',
accessToken: 'shpua_XXXXXXXXXXXXXXXXXXXXXX'
}
And the sessionCopy objects, as logged in console:
{
shop: 'X.myshopify.com',
scope: 'read_orders',
isOnline: false,
id: 'offline_X.myshopify.com',
state: '358222388575483',
accessToken: 'shpua_XXXXXXXXXXXXXXXXXXXXXX',
onlineAccessInfo: undefined,
expires: undefined
}
Calling “const restClient = new shopify.clients.Rest({sessionCopy});” triggers the error “Cannot read properties of undefined (reading ‘accessToken’)”. Diving into the library’s “client.js” it appears the session object is undefined.
Am I creating the session wrong?