commit ca0e568f9e4a7f236bb1c7957690adad79fb4de5 Author: Abhishek Test Tiwari Date: Fri Jun 27 10:30:42 2025 +0000 code update recorded at: 27/06/25 10:30:42 diff --git a/handler.js b/handler.js new file mode 100644 index 0000000..b4f5f1e --- /dev/null +++ b/handler.js @@ -0,0 +1,19 @@ +export const handler = async (req, res, next) => { + try { + const { num1, num2 } = req.body; + console.log(req); + // Validate the input + if (typeof num1 !== 'number' || typeof num2 !== 'number') { + return res.status(400).json({ error: 'Both num1 and num2 must be numbers.' }); + } + const sum = num1 + num2; + console.log(sum); + // Send the result as a string since res.end expects a string or buffer + res.end(sum.toString()); + } catch (error) { + // Handle errors + console.error('Error occurred:', error.message); + // Send an error response if needed + res.status(500).setHeader('Content-Type', 'text/plain').end('Internal Server Error'); + } +}; \ No newline at end of file