Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

Consider following code -

function index(event, context, callback) {

  //some code

}

exports.handler = index();

{

  "errorMessage": "Handler 'handler' missing on module 'index'"

}

This is my function which is having business logic. My javascript file name is index.js.

Whenever I test this code on aws lambda, It gives the following log(failed).

This is a screenshot of the Amazon Lambda Upload Site: 

image

1 Answer

0 votes
by (44.4k points)

Reference the index function in export.handler, but the result of its execution. I guess you have to import the function itself.

let index = function index(event, context, callback) {

  //some code

}

exports.handler = index;

Or directly

exports.handler = function index(event, context, callback) {

  //some code

}

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...