简体   繁体   English

AWS Lambda:测试事件配置:JSON事件错误

[英]aws lambda: test event configuration: Error in JSON event

I have deployed a node js app to AWS lambda . 我已将node js应用程序部署到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. 您的JSON事件发生错误。 Please correct it before saving. 保存前请更正它。

This is the configuration of lambda function you have created. 这是您创建的lambda函数的配置。 So click on the lambda function first. 因此,请首先单击lambda函数。 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. 之后,您可以像以前一样进行测试。 在此处输入图片说明 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM