Spaces:
Runtime error
Runtime error
File size: 525 Bytes
a86df80 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import { toOpenAI } from "@/services/api";
import { NextApiRequest, NextApiResponse } from "next";
import { AxiosError } from "axios";
export default async function handler(request: NextApiRequest, response: NextApiResponse) {
switch (request.method) {
case "POST":
try {
const answer = await toOpenAI(request.body);
return response.status(200).json(answer);
} catch (error) {
return response.status((error as AxiosError).status ?? 500).end();
}
default:
return response.status(405).end();
}
}
|