Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aws lambda: test event configuration: Error in JSON event

I have deployed a node js app to AWS lambda. I have the following code in my test event :

function getRoutes(callback){
    request('http://localhost/php-rest/api.php/routes?filter=route_short_name', function(error, response, body) {
        if (!error && response.statusCode == 200) {
            message = JSON.stringify(JSON.parse(body));
            return callback(message, false);
        } else {
            return callback(null, error);;
        }
    });
}

app.get('/getRoutes', function(req, res) {

    getRoutes(function(err, data){
        if(err) return res.send(err);
        res.send(data);
    });

});

I got the following error when I tried to save that:

There is an error in your JSON event. Please correct it before saving.

like image 517
Rashik Avatar asked Sep 16 '25 05:09

Rashik


1 Answers

This is the configuration of lambda function you have created. So click on the lambda function first. After that you will get a window called function code. There you have to write you handler. After that you can test like you did before. enter image description hereenter image description here

like image 78
SamPiy93 Avatar answered Sep 18 '25 18:09

SamPiy93