0

Am trying to get data using postman but am getting handler method did not return a value yet i can console.log results. What might be the problem with my code?

{
    method: 'GET',
    path: '/departments',
    handler: (request, h) => {
        // let results=[];
        connection.query('SELECT * FROM departments', function (Error, results) {
            if (Error) {
                console.log(Error);
                return Error;
            }
            console.log(JSON.stringify(results));
        });
        return h.response(results);   
    }
}
Robert
  • 7,394
  • 40
  • 45
  • 64
Sam
  • 1
  • 1
  • 1
  • Possible duplicate of [Error: handler method did not return a value, a promise, or throw an error](https://stackoverflow.com/questions/54862193/error-handler-method-did-not-return-a-value-a-promise-or-throw-an-error) – optimisticupdate Mar 01 '19 at 18:52
  • I also have this exact same problem. If anyone can answer this, you're a lifesaver – bradrar Apr 05 '19 at 11:08

0 Answers0