function handler(lambda) {
    return async function (event, context) {
        let body, statusCode;

        try {  // Run the Lambda
            body = await lambda(event, context);
            statusCode = 200;
        } catch (e) {
            body = { error: e.message };
            statusCode = 500;
        }

        // Return HTTP response
        return {
            statusCode,  // 200 if it's successful, 500 if it's not
            body: JSON.stringify(body),
        };
    };
}
// it takes in a lambda function as an argument
it takes in a lambda function as an argument
it takes in a lambda function as an argument
function handler(lambda) {
    return async function (event, context) {
        let body, statusCode;
        try {  
            body = await lambda(event, context);
            statusCode = 200;
        } catch (e) {
            body = { error: e.message };
            statusCode = 500;
        }
        return {
            statusCode,  
            body: JSON.stringify(body),
        };
    };
}
function handler ( lambda ) { return async function ( event , context ) { let body , statusCode ; try { body = await lambda ( event , context ) ; statusCode = 200 ; } catch ( e ) { body = { error : e . message } ; statusCode = 500 ; } return { statusCode , body : JSON . stringify ( body ) , } ; } ; }
it takes in a lambda function as an argument
it takes in a lambda function as an argument
// Run the Lambda // Return HTTP response // 200 if it's successful, 500 if it's not