Strapi-sdk-js pls help

const isProd = process.env.IS_PRODUCTION === “true” ? true : false;

export const strapi = {
find: async function getItem(
path: string,
isPublic = false,
cache = false
): Promise<{ data: T } | undefined> {
try {
const endpoint = isPublic
? process.env.NEXT_PUBLIC_STRAPI_URL
: process.env.STRAPI_URL;

  const url = isProd
    ? `${endpoint}/api/${path}`
    : `${endpoint}/api/${path}&publicationState=preview`; // Show Preview Mode on stage

  const resp = await fetch(url, {
    cache: cache ? "force-cache" : "no-store",
  });
  if (!resp.ok) {
    throw new Error("Error fetching data");
  }

  const data = await resp.json();
  return data as { data: T };
} catch (error) {
  console.log(error);
}

},
};

does anyone knows what’s wrong? Recently, It is working but now it is not. Even if I change the url to http://localhost:1337 it’s still not working.

This topic has been created from a Discord post (1253032205429772289) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord