如何通过JavaScript从返回AWS Lambda函数获取价值

时间:2019-05-15 10:00:40

标签: javascript node.js json aws-lambda

标题##我无法从另一个lambda函数(转换器)到调用方lambda函数获取“名称”或“城市”值。

//////////////////////////// 来电者Lambda函数:/// /////////////////////////

df <- structure(list(Groups = c("G1", "G1", "G1", "G1", "G2", "G2", 
"G2"), Name = c("A", "A", "B", "B", "A", "C", "C"), Category = 
c("cat1", "cat2", "cat3", "cat3", "cat4", "cat2", "cat2"), value = 
c(20L, 1L, 21L, 23L, 32L, 23L, 21L)), class = "data.frame", row.names = 
c(NA, -7L))

//////////////////////////// Callee Lambda函数:/// /////////////////////////

var AWS = require('aws-sdk');
AWS.config.region = 'us-west-2';
var lambda = new AWS.Lambda();

exports.handler  = function(event, context)  {

var data =  {
 message : event.message
}

var datapayload = JSON.stringify(data);

var params = {
FunctionName: 'Translator', // the lambda function we are going to invoke
InvocationType: 'RequestResponse',
LogType: 'None',
Payload: datapayload
};


var pullResults;

lambda.invoke(params, function(err, data) {
if (err) {
  //context.fail(err);
  prompt(err);
} else {

   pullResults = JSON.parse(data.Payload);
   console.log(pullResults.name);
  // prompt(pullResults.isWinner);
  //context.succeed(data.Payload);

}


})

const response = {

    statusCode: 200,
    body: JSON.stringify("12"),
};
return response;


};

0 个答案:

没有答案