0

When I am doing following:

async function xyz(id) {
    await client.getCall(id, {}, 
        function(err, data, response) {
            return {
                statusCode: 200,
                body: data
            };
        }
    );
}

It is not working and return the null body while when I try this:

async function xyz(id) {
    var data1 = "";
    await client.getCall(id, {}, 
        function(err, data, response) {
            data1 = data;
        }
    );

    return {
      statusCode: 200,
      body: data1
    };
}

It works fine. Any idea why/

hatellla
  • 4,796
  • 8
  • 49
  • 101
  • 1
    `client.getCall` seems to not return the return value of its callback - where does `client` come from? some library? – Turtlefight Aug 20 '19 at 20:50
  • You can only `await` a promise. `getCall` very unlikely does return one when it takes a callback. – Bergi Aug 20 '19 at 21:20

0 Answers0