The route with GET method works but the route with the POST method doesn't work. The postman is keep running and doesn't respond with a response.
Here is what I have tried,
import * as hapi from "@hapi/hapi";
const init = async () => {
const server: hapi.Server = new hapi.Server({
port: 3000,
host: 'localhost'
});
server.route({
method: 'POST', // if you change it to GET, it works
path: '/test',
handler: function (request, h) {
const payload = { username: 'testUserNames'};
return payload.username;
}
});
await server.start();
console.log('Server running on %s', server.info.uri);
}
process.on('unhandledRejection', (err) => {
console.log(err);
process.exit(1);
});
init();
What could be the issue? where am I wrong?
i had the same problem and i solved it by downgrading to node v14. for some reason the hapi framework isn't compatible with node v16.