When I run on localhost:3000 all systems run smoothly without any problems, but when I run npm run build
I get the error:
Property 'status' does not exist in type 'NextApiResponse<Data>'.ts(2339)
This is the code I use:
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import { retrieveData } from '@/lib/firebase/services';
import type { NextApiRequest, NextApiResponse } from 'next';
type Data = {
status: boolean;
statusCode: number;
data: any;
};
export default async function handler(
req: NextApiRequest,
res: NextApiResponse<Data>
) {
const data = await retrieveData("products");
res.status(200).json({ status: true, statusCode: 200, data });
}
This is the error that appears on res.status(200).json({ status: true, statusCode: 200, data });
:
and this is the error image when I run npm run build
:
This is the configuration of the file .eslintrc.json
:
{
"extends": "next/core-web-vitals",
"rules": {
"react-hooks/exhaustive-deps": "off"
}
}
Can anyone help me in this problem?