API Routes App Router
Unanswered
Hunter Bertoson posted this in #help-forum
I have /app/api/route.ts and this function
This works great. But if I try to do
I get an error that says res.status is not a function and also res.json is not a function. But Typescript is not complaining. Any ideas?
import {NextApiRequest, NextApiResponse} from 'next';
export function GET(req: NextApiRequest, res: NextApiResponse) {
return new Response('Hello World', {status: 202});
}This works great. But if I try to do
import {NextApiRequest, NextApiResponse} from 'next';
export function GET(req: NextApiRequest, res: NextApiResponse) {
res.status(202).json({message: 'Hello World'});
}I get an error that says res.status is not a function and also res.json is not a function. But Typescript is not complaining. Any ideas?