return value from lambda function [duplicate]How do I return the response from an asynchronous call?AWS Lambda - Nodejs function will not return dataIs there an “exists” function for jQuery?Which “href” value should I use for JavaScript links, “#” or “javascript:void(0)”?How do I remove a property from a JavaScript object?var functionName = function() vs function functionName() Set a default parameter value for a JavaScript functionHow can I get query string values in JavaScript?Sort array of objects by string property valueevent.preventDefault() vs. return falseHow do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?

Do the temporary hit points from Reckless Abandon stack if I make multiple attacks on my turn?

Why Were Madagascar and New Zealand Discovered So Late?

Is a stroke of luck acceptable after a series of unfavorable events?

Type int? vs type int

Why escape if the_content isnt?

Is there a problem with hiding "forgot password" until it's needed?

Two monoidal structures and copowering

What is paid subscription needed for in Mortal Kombat 11?

How can I kill an app using Terminal?

What does the word "Atten" mean?

Avoiding estate tax by giving multiple gifts

How can I get through very long and very dry, but also very useful technical documents when learning a new tool?

How does the UK government determine the size of a mandate?

Was Spock the First Vulcan in Starfleet?

How to Reset Passwords on Multiple Websites Easily?

Is this apparent Class Action settlement a spam message?

Opposite of a diet

CREATE opcode: what does it really do?

System.debug(JSON.Serialize(o)) Not longer shows full string

Lay out the Carpet

You cannot touch me, but I can touch you, who am I?

Would this custom Sorcerer variant that can only learn any verbal-component-only spell be unbalanced?

Applicability of Single Responsibility Principle

Do sorcerers' subtle spells require a skill check to be unseen?



return value from lambda function [duplicate]


How do I return the response from an asynchronous call?AWS Lambda - Nodejs function will not return dataIs there an “exists” function for jQuery?Which “href” value should I use for JavaScript links, “#” or “javascript:void(0)”?How do I remove a property from a JavaScript object?var functionName = function() vs function functionName() Set a default parameter value for a JavaScript functionHow can I get query string values in JavaScript?Sort array of objects by string property valueevent.preventDefault() vs. return falseHow do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?













0
















This question already has an answer here:



  • How do I return the response from an asynchronous call?

    33 answers



  • AWS Lambda - Nodejs function will not return data

    1 answer



const AWS = require('aws-sdk');

exports.handler = (event) =>
AWS.config.update(region: 'eu-west-1');
var cw = new AWS.CloudWatch(apiVersion: '2010-08-01');

var alarmStatus = ;
cw.describeAlarms(, function(err, data)
if (err)
console.log("Error", err);
else
data.MetricAlarms.forEach(function (item, index, array)
var pair = [item.AlarmName]: item.StateValue;
alarmStatus = ...alarmStatus, ...pair;
console.log(alarmStatus);
);

);

const response =
statusCode: 200,
body: JSON.stringify(alarmStatus),
;
return response;
;


I want to send response back to the caller of the lambda function, but since describe alarm function of cloudwatch is asynchronous, I am getting empty response in the body. How can I wait for the function to execute before returning the response?










share|improve this question













marked as duplicate by deceze javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 7 at 12:55


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • Is it perhaps an option to add an obserable for alarmStatus? If the value changed, return the response.

    – Jordec
    Mar 7 at 12:56











  • why not put response in the else part of the describeAlarms?

    – Mahendra suthar
    Mar 7 at 13:28











  • @Mahendrasuthar Putting response in else part is sending null in response. I guess, we can't have return statement inside the callback. I am not sure about that. In my case it is not working

    – Bharthan
    Mar 7 at 13:33












  • async would be a great choice here..more info @ caolan.github.io/async

    – Mahendra suthar
    Mar 7 at 13:47















0
















This question already has an answer here:



  • How do I return the response from an asynchronous call?

    33 answers



  • AWS Lambda - Nodejs function will not return data

    1 answer



const AWS = require('aws-sdk');

exports.handler = (event) =>
AWS.config.update(region: 'eu-west-1');
var cw = new AWS.CloudWatch(apiVersion: '2010-08-01');

var alarmStatus = ;
cw.describeAlarms(, function(err, data)
if (err)
console.log("Error", err);
else
data.MetricAlarms.forEach(function (item, index, array)
var pair = [item.AlarmName]: item.StateValue;
alarmStatus = ...alarmStatus, ...pair;
console.log(alarmStatus);
);

);

const response =
statusCode: 200,
body: JSON.stringify(alarmStatus),
;
return response;
;


I want to send response back to the caller of the lambda function, but since describe alarm function of cloudwatch is asynchronous, I am getting empty response in the body. How can I wait for the function to execute before returning the response?










share|improve this question













marked as duplicate by deceze javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 7 at 12:55


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • Is it perhaps an option to add an obserable for alarmStatus? If the value changed, return the response.

    – Jordec
    Mar 7 at 12:56











  • why not put response in the else part of the describeAlarms?

    – Mahendra suthar
    Mar 7 at 13:28











  • @Mahendrasuthar Putting response in else part is sending null in response. I guess, we can't have return statement inside the callback. I am not sure about that. In my case it is not working

    – Bharthan
    Mar 7 at 13:33












  • async would be a great choice here..more info @ caolan.github.io/async

    – Mahendra suthar
    Mar 7 at 13:47













0












0








0









This question already has an answer here:



  • How do I return the response from an asynchronous call?

    33 answers



  • AWS Lambda - Nodejs function will not return data

    1 answer



const AWS = require('aws-sdk');

exports.handler = (event) =>
AWS.config.update(region: 'eu-west-1');
var cw = new AWS.CloudWatch(apiVersion: '2010-08-01');

var alarmStatus = ;
cw.describeAlarms(, function(err, data)
if (err)
console.log("Error", err);
else
data.MetricAlarms.forEach(function (item, index, array)
var pair = [item.AlarmName]: item.StateValue;
alarmStatus = ...alarmStatus, ...pair;
console.log(alarmStatus);
);

);

const response =
statusCode: 200,
body: JSON.stringify(alarmStatus),
;
return response;
;


I want to send response back to the caller of the lambda function, but since describe alarm function of cloudwatch is asynchronous, I am getting empty response in the body. How can I wait for the function to execute before returning the response?










share|improve this question















This question already has an answer here:



  • How do I return the response from an asynchronous call?

    33 answers



  • AWS Lambda - Nodejs function will not return data

    1 answer



const AWS = require('aws-sdk');

exports.handler = (event) =>
AWS.config.update(region: 'eu-west-1');
var cw = new AWS.CloudWatch(apiVersion: '2010-08-01');

var alarmStatus = ;
cw.describeAlarms(, function(err, data)
if (err)
console.log("Error", err);
else
data.MetricAlarms.forEach(function (item, index, array)
var pair = [item.AlarmName]: item.StateValue;
alarmStatus = ...alarmStatus, ...pair;
console.log(alarmStatus);
);

);

const response =
statusCode: 200,
body: JSON.stringify(alarmStatus),
;
return response;
;


I want to send response back to the caller of the lambda function, but since describe alarm function of cloudwatch is asynchronous, I am getting empty response in the body. How can I wait for the function to execute before returning the response?





This question already has an answer here:



  • How do I return the response from an asynchronous call?

    33 answers



  • AWS Lambda - Nodejs function will not return data

    1 answer







javascript node.js aws-lambda






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 7 at 12:53









BharthanBharthan

6291620




6291620




marked as duplicate by deceze javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 7 at 12:55


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by deceze javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 7 at 12:55


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • Is it perhaps an option to add an obserable for alarmStatus? If the value changed, return the response.

    – Jordec
    Mar 7 at 12:56











  • why not put response in the else part of the describeAlarms?

    – Mahendra suthar
    Mar 7 at 13:28











  • @Mahendrasuthar Putting response in else part is sending null in response. I guess, we can't have return statement inside the callback. I am not sure about that. In my case it is not working

    – Bharthan
    Mar 7 at 13:33












  • async would be a great choice here..more info @ caolan.github.io/async

    – Mahendra suthar
    Mar 7 at 13:47

















  • Is it perhaps an option to add an obserable for alarmStatus? If the value changed, return the response.

    – Jordec
    Mar 7 at 12:56











  • why not put response in the else part of the describeAlarms?

    – Mahendra suthar
    Mar 7 at 13:28











  • @Mahendrasuthar Putting response in else part is sending null in response. I guess, we can't have return statement inside the callback. I am not sure about that. In my case it is not working

    – Bharthan
    Mar 7 at 13:33












  • async would be a great choice here..more info @ caolan.github.io/async

    – Mahendra suthar
    Mar 7 at 13:47
















Is it perhaps an option to add an obserable for alarmStatus? If the value changed, return the response.

– Jordec
Mar 7 at 12:56





Is it perhaps an option to add an obserable for alarmStatus? If the value changed, return the response.

– Jordec
Mar 7 at 12:56













why not put response in the else part of the describeAlarms?

– Mahendra suthar
Mar 7 at 13:28





why not put response in the else part of the describeAlarms?

– Mahendra suthar
Mar 7 at 13:28













@Mahendrasuthar Putting response in else part is sending null in response. I guess, we can't have return statement inside the callback. I am not sure about that. In my case it is not working

– Bharthan
Mar 7 at 13:33






@Mahendrasuthar Putting response in else part is sending null in response. I guess, we can't have return statement inside the callback. I am not sure about that. In my case it is not working

– Bharthan
Mar 7 at 13:33














async would be a great choice here..more info @ caolan.github.io/async

– Mahendra suthar
Mar 7 at 13:47





async would be a great choice here..more info @ caolan.github.io/async

– Mahendra suthar
Mar 7 at 13:47












0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

1928 у кіно

Захаров Федір Захарович

Ель Греко