Error when upgrading Remix, Response.json is not a function

I faced the same error when returning Response.json(…) in the loader. I’m using the image 20.18.0-alpine in the container (production) and node 20.18.0 in my local machine. The weird part is that this works well in my machine, but fails in docker. I solved it using the function data (import { data } from ‘@remix-run/node’) and it works well.

Like in the example:

-import { json } from "@remix-run/node";
+import { data } from "@remix-run/node";

export async function loader({}: LoaderFunctionArgs) {
  let tasks = await fetchTasks();
-  return json(tasks, {
+  return data(tasks, {
    headers: {
      "Cache-Control": "public, max-age=604800"
    }
  });
}

1 Like