Focuses on API authentication, access scopes, and permission management.
Hello! Apologies if this isnt the correct place to post this --
I'm currently developing a Shopify app using the Remix framework and have encountered an issue I can't seem to resolve. I'm experiencing a TypeError related to the Shopify REST client within my Remix app, and despite following the Shopify documentation closely, I'm stuck. I'm hoping to get some insights or suggestions from the community.
When running my app, I encounter the following error:
Application Error
TypeError: Cannot read properties of undefined (reading 'shop')
at new RestClient ...
This error appears when I try to fetch data from Shopify, such as abandoned checkouts or shop details.
Here's an excerpt from my shopify.server.jsx where I configure the Shopify app:
// shopify.server.jsx
import "@shopify/shopify-app-remix/adapters/node";
import { shopifyApp, LATEST_API_VERSION } from "@shopify/shopify-app-remix/server";
import { PrismaSessionStorage } from "@shopify/shopify-app-session-storage-prisma";
import { restResources } from "@shopify/shopify-api/rest/admin/2023-10";
import prisma from "./db.server";
const shopify = shopifyApp({
apiKey: process.env.SHOPIFY_API_KEY,
apiSecretKey: process.env.SHOPIFY_API_SECRET || "",
apiVersion: LATEST_API_VERSION,
scopes: process.env.SCOPES?.split(","),
appUrl: process.env.SHOPIFY_APP_URL || "",
sessionStorage: new PrismaSessionStorage(prisma),
restResources,
// Additional configurations...
});
export default shopify;
And here's how I'm trying to fetch abandoned checkouts:
// Part of shopify.server.jsx
export async function fetchAbandonedCheckouts(admin) {
try {
console.log("Session details:", admin.session);
const response = await admin.rest.resources.AbandonedCheckout.checkouts({
session: admin.session,
});
return response.body.checkouts;
} catch (error) {
console.error("Error fetching abandoned checkouts:", error);
throw error;
}
}
[Terminal Output]
10:25:56 │ remix │ Session details: undefined
10:25:56 │ remix │ Shop Details: undefined
10:25:56 │ remix │ Error fetching abandoned checkouts: TypeError: Cannot read properties of undefined (reading 'shop')
...
Hi Mikebatts,
Are you seeing any error codes that we can look into?
Hope this helps!
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog