https://github.com/Elliott-Chong/chatpdf-yt/issues/43
This is the github link of the issue.
The error is as follows:
FileUpload.tsx:22
POST http://localhost:3000/api/createchat 500 (Internal Server Error)
mutationFn @ FileUpload.tsx:22
Promise.then (async)
onDrop @ FileUpload.tsx:53
I have tried debugging and i guess that the error is in the code:
mutationFn: async ({
file_key,
file_name,
}: {
file_key: string;
file_name: string;
}) => {
const response = await axios.post("/api/createchat", {
file_key,
file_name,
});
return response.data;
//console.log(response);
},
});
This is the route.ts file under /api/createchat
import { loadS3IntoPinecone } from "@/lib/pinecone";
import { NextResponse } from "next/server";
export async function POST(req: Request) {
try {
const body = await req.json();
const {file_key, file_name} = body;
console.log(file_key,file_name);
const pages = await loadS3IntoPinecone(file_key);
return NextResponse.json({ pages });
} catch (error) {
console.error(error);
return NextResponse.json(
{error: "internal server error"},
{status: 500}
);
}
}