【发布时间】:2019-09-03 18:54:35
【问题描述】:
我在 AWS API Gateway 中定义了一个使用 Lambda 集成的端点。 Lambda 函数需要在传递给它的 event 对象中可用的查询字符串参数。
我的 API 位于 example.execute-api.us-east-1.amazonaws.com/dev/my-resource,并且我有查询字符串参数,例如 foo=test。
所以完整的端点是
example.execute-api.us-east-1.amazonaws.com/dev/my-resource?foo=test
我可以在浏览器中访问此端点或在邮递员中请求它,并获得预期的响应,因此我知道 API 网关配置正确。但是,当我使用 Javascript SDK 时,我似乎无法传递查询字符串参数。
根据this page from the docs 的最后一部分,我应该能够只传递一个 JSON 对象,该对象将被解释为查询字符串参数,如下所示:
var apiClient = apigClientFactory.newClient();
var requestParams = {"foo": "test"};
apiClient.myResourceGet(requestParams).then(function(result) {
// Do something with the response
});
但是,就我而言,requestParams 似乎被忽略了。在 Lambda 函数中,event 有一个空的 queryStringParameters 字段。 如何将requestParams 对象中定义的键/值作为查询字符串参数传递给此端点?
【问题讨论】:
标签: amazon-web-services aws-lambda aws-api-gateway