Before deploying my app, I updated Remix to version 2.13.1, when I did it, I had deprecated on the json response provided by Remix:
This utility is deprecated in favor of opting into Single Fetch via future. v3_singleFetch and returning raw objects. This method will be removed in React Router v7. If you need to return a JSON Response, you can use Response. json().
So I used Response.json() in my code, it works without issues when I use shopify app dev
, all my code works.
But when I deployed my app on my cluster, and built it, I have this error when I want to try my app in dev mode:
[shopify-api/INFO] Creating new session | {shop: quickstart-XXXXX.myshopify.com, isOnline: false}
TypeError: Response.json is not a function
at loader (file:///app/build/server/index.js?t=1732184518000:4154:19)
at Object.callRouteLoader (/app/node_modules/@remix-run/server-runtime/dist/data.js:59:16)
at /app/node_modules/@remix-run/router/router.ts:4899:19
at callLoaderOrAction (/app/node_modules/@remix-run/router/router.ts:4963:16)
at async Promise.all (index 0)
at defaultDataStrategy (/app/node_modules/@remix-run/router/router.ts:4772:17)
at callDataStrategyImpl (/app/node_modules/@remix-run/router/router.ts:4835:17)
at callDataStrategy (/app/node_modules/@remix-run/router/router.ts:3992:19)
at loadRouteData (/app/node_modules/@remix-run/router/router.ts:3937:19)
at queryImpl (/app/node_modules/@remix-run/router/router.ts:3696:20)
The code from index.js
is:
const loader = async ({ request }) => {
await authenticate.admin(request);
const user = await getAuthenticatedUser();
return Response.json({
apiKey: process.env.SHOPIFY_API_KEY || "",
authenticatedUser: user
});
};
Can I use Response.json already ? Or should I wait ? Why the embedded app doesn’t work but the dev version yes ?
Thanks