import { NextApiRequest, NextApiResponse } from 'next'; const handler = (req: NextApiRequest, res: NextApiResponse) => { const tasks = []; // Fetch tasks from API fetch('https://api.example.com/tasks') .then((response) => response.json()) .then((data) => { tasks = data; res.json(tasks); }) .catch((error) => { console.error(error); res.status(500).json({ message: 'Error fetching tasks' }); }); }; export default handler;