You should return a Promise and resolve/reject it.
Example:
import { getData } from "../../helper";
export default async function(req, res) {
return new Promise((resolve, reject) => {
getData()
.then(response => {
res.statusCode = 200
res.setHeader('Content-Type', 'application/json');
res.setHeader('Cache-Control', 'max-age=180000');
res.end(JSON.stringify(response));
resolve();
})
.catch(error => {
res.json(error);
res.status(405).end();
resolve(); // in case something goes wrong in the catch block (as vijay commented)
});
});
};