TypeError: fetch failed in code, even though it runs properly on the server
Unanswered
Le Conte's Sparrow posted this in #help-forum
Le Conte's SparrowOP
I am trying make a GET request using fetch api, and I get a TypeError. I am using TS.
Error:
function in utils/index.ts
and my page.tsx
Error:
Unhandled Runtime Error
Error: fetch failed
Call Stack
Object.fetch
node:internal/deps/undici/undici (11118:11)
process.processTicksAndRejections
node:internal/process/task_queues (95:5)function in utils/index.ts
export async function fetchShowData() {
const headers = {
Authorization: "Bearer KEY",
};
const url = "https://animeschedule.net/api/v3/timetables";
const response = await fetch(url, { headers: headers });
const calendarData = await response.json();
return calendarData;
}and my page.tsx
import { fetchShowData } from "@/utils";
export default async function Home() {
const allAnime = await fetchShowData();
console.log(allAnime);
return (
<div>
<main>test</main>
</div>
);
}2 Replies
Le Conte's SparrowOP
I think I made a typo in the title, what I meant was, it runs properly on the console
so, chrome => f12 => copy-paste, and it runs