import { trpc } from "@acme/app/utils/trpc";
import { NextApiRequest, NextApiResponse } from "next";
export default async function handler(
req: NextApiRequest,
res: NextApiResponse,
) {
const { method } = req;
const { data } = trpc.lesson.all.useQuery();
console.log("data", data);
switch (method) {
case "GET":
try {
res.status(200).json({ success: true, data: data });
} catch (error) {
res.status(400).json({ success: false, error: error });
}
}
}
import { trpc } from "@acme/app/utils/trpc";
import { NextApiRequest, NextApiResponse } from "next";
export default async function handler(
req: NextApiRequest,
res: NextApiResponse,
) {
const { method } = req;
const { data } = trpc.lesson.all.useQuery();
console.log("data", data);
switch (method) {
case "GET":
try {
res.status(200).json({ success: true, data: data });
} catch (error) {
res.status(400).json({ success: false, error: error });
}
}
}