Closed nickheady closed 1 month ago
Hey @nickheady,
thanks for reporting this issue. Could it be that this line
const restClient = new shopify.clients.Rest({sessionCopy});
should instead be
const restClient = new shopify.clients.Rest({session: sessionCopy});
We are closing this issue because we did not hear back regarding additional details we needed to resolve this issue. If the issue persists and you are able to provide the missing clarification we need, feel free to respond and reopen this issue.
We appreciate your understanding as we try to manage our number of open issues.
I have a cloud function whose purpose is to get the shop's orders.
I create the shopify object:
Then I pull the session data from the database and create the rest client and make a call:
But I get this error:
TypeError: Cannot read properties of undefined (reading 'accessToken')
From this line:(/node_modules/@shopify/shopify-api/dist/cjs/lib/clients/admin/rest/client.js:27:50)
which is inside the rest client constructor, this if statement:So 'session' is undefined here. I cannot figure out why.
sessionData
is just an object with these properties:After creating a new session with
const sessionCopy = new Session(sessionData);
thesessionCopy
object contains the above plus: