Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  7] [ 5]  / answers: 1 / hits: 18604  / 7 Years ago, wed, december 20, 2017, 12:00:00

I am loving using lambda functions in AWS. It ideally reduced my time in maintaining the servers anymore. My question is when using lambda there is context object and the callback function to terminate the function. Is there any use case of using callback over context.



Could anyone tell me the behavior of context.succeed() to callback(error,message)



var startedAt = new Date();

var interval = setInterval(function () {
console.log(startedAt, new Date());
}, 1000);

exports.handler = function (event, context, callback) {
setTimeout(function () {
console.log('returning');
// v1:
return callback(null);
// v2:
// return context.succeed();
}, 5000);
};

More From » node.js

 Answers
10

context.succeed is the older way of doing things, and is supported under the 0.10.42 runtime (where the callback parameter specifically isn't). If you're running on the newer runtimes (4.3 and 6.10), it's included for backwards compatibility, but the proper way is now to use the callback functionality.


[#55626] Monday, December 18, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jackelyn

Total Points: 303
Total Questions: 103
Total Answers: 102

Location: Turks and Caicos Islands
Member since Sun, Mar 7, 2021
3 Years ago
jackelyn questions
Thu, Apr 8, 21, 00:00, 3 Years ago
Sun, Feb 28, 21, 00:00, 3 Years ago
Mon, May 25, 20, 00:00, 4 Years ago
Thu, Apr 30, 20, 00:00, 4 Years ago
;