Here is a next.js handler function for handling api requests on our server. I am looking for assistance on how to access a variable between request methods. Any help would be greatly appreciated.
export default function handler(req, res) {
if(req.method === 'POST') {
var hi = req.body
}
if (req.method === 'GET') {
console.log(hi)
}
}