Reputation: 141
I am using a nodejs application and w.r.t this link :- http://blog.rowanudell.com/testing-serverless-functions-locally/.
I was able to call the lambda function locally with the command : $ lambda-local -f index.js
on CLI.
Is there a way to trigger the same from inside a .js file of nodejs application?
Upvotes: 1
Views: 1249
Reputation: 3993
This should do the job:
// set the event data you want here
const event = {};
// mock the context if needed here
const context = {};
// retrieve the result of the lambda here
const cb = (err, res) => {
console.log(err, res);
};
// load the file containing the Lambda handler
const lambda = require("./path/to/index.js");
// call the handler
lambda.handler(event, context, cb);
Upvotes: 1