Lambda function does not return any postgres result while debugging

Viewed 8

I am trying to execute simple PG database read from lambda. Database seems to get connect however i am not getting any results. Neither gives error.

its just bypass the code block and move on

exports.lambdaHandler = async (event, context) => {

const client = new Client({
    user: 'postgres',
    password: 'pass',
    database: 'dbdev',
    host: 'host',
  })
  

await client.connect();

try {
    // const ret = await axios(url);

    const query = 'select * FROM post_requests.property_header';

   await  client.query(query, async (error,res) => {
        if (error) {
            return
        }
        console.log(res);
        })
        ;

    response = {
        'statusCode': 200,
        'body': JSON.stringify({
            message: 'hello world',
            // location: ret.data.trim()
        })
    }
} catch (err) {
    console.log(err);
    return err;
}

return response

};

0 Answers
Related