Hi everyone,
I'm using Next.js 13 with appDirectory.
I'm experiencing weird issue, I have a route /api/events
app/api/events/routes.ts
import { client } from '@/contentful/setup';
import { NextResponse } from 'next/server';
export async function GET(request: Request) {
const res = await client.getEntries({
content_type: 'events' // only fetch blog post entry
});
return NextResponse.json(res.items);
}
I can see the json when going to http://localhost/api/events BUT I can't read the json from the client
async function getEvents() {
const res = await fetch('/api/events', { method: 'GET' });
return res;
}
export default function Home() {
// using react-query here
const { isLoading, isError, data, error } = useQuery({
queryKey: ['events'],
queryFn: getEvents
});
console.log(data)
return (<></>)
}
and i got this log and can't read the body.. :
Response {type: 'basic', url: 'http://localhost:3000/api/events', redirected: false, status: 200, ok: true, …}
body: ReadableStream
bodyUsed: false
headers: Headers {}
ok: true
redirected: false
status: 200
statusText: "OK"
type: "basic"
url: "http://localhost:3000/api/events"
Any hint ?