I am trying make a GET request using fetch api, and I get a TypeError. I am using TS.
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
```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
```ts
import { fetchShowData } from "@/utils";
export default async function Home() {
const allAnime = await fetchShowData();
console.log(allAnime);
return (
<div>
<main>test</main>
</div>
);
}```