#api route not detected

1 messages · Page 1 of 1 (latest)

surreal garnet
#

hi, im new in remix, i want to ask
why my api route is error when i deploy at vercel this is little bit of my api code:

api.anime.ts
import { LoaderFunction } from "@remix-run/server-runtime";
import dataFetcher, { baseUrl } from "~/libs/dataFetcher.server";

export const loader: LoaderFunction = async ({ request }) => {
  const url = new URL(request.url);
  const page = url.searchParams.get("page");
  const fetcher = new dataFetcher();

  try {
    const { animeLinks, pagination } = await fetcher.aniFetch(
      page === "1" ? undefined : `${baseUrl}/page/${page}`
    );

    return new Response(JSON.stringify({ animeLinks, pagination }), {
      headers: {
        "Content-Type": "application/json",
      },
    });
  } catch (error) {
    return new Response(JSON.stringify({ error: "Failed to fetch data" }), {
      status: 500,
      headers: {
        "Content-Type": "application/json",
      },
    });
  }
};
#

are that is wrong?

elfin cipher
#

You didn't say what the error was.