从AWS中的lambda函数返回后,变量为null

时间:2017-05-07 12:17:21

标签: node.js amazon-web-services aws-lambda

我尝试定义局部变量,然后调用lambda函数,该函数将值填充到我的局部变量:

var listOfAliases = null;
lambda.invoke(params, function(err, data) {
    if (err) {
        //context.fail(err);
        console.log(`This is the ERROR execution =${err} =================================`);
        prompt(err);
    } else {
        //context.succeed('Data loaded from DB: '+ data.Payload);
        listOfAliases = JSON.stringify(data.Payload);
        console.log(`This is the VALIDE execution =${data.Payload} =================================`); //I can see this in the log with proper values
        console.log(`This is the VALIDE execution(listOfAliases) =${listOfAliases} =================================`); //I can see this in the log with proper values

    }
    callback(null, JSON.parse(data.Payload));
});

console.log(`This is the DB execution listOfAliases=${listOfAliases} =================================`); //I can see this in the log with NULL value

0 个答案:

没有答案