【发布时间】:2020-03-29 20:26:04
【问题描述】:
这是我的代码,它从 Amazon Fargate 服务上运行的服务之一向 API 端点发出 Http Get 请求。该 API 由 Amazon API 网关和 Lambda 提供支持。这也是在 VPC 中使用的私有 api,我还设置了 apigateway VPC 端点以促进相同的操作。我只收到过一次这个错误。随后对 API 的所有调用均成功。
我怀疑 lambda 不温暖,导致超时。我将尝试为 axios 代码设置超时。欢迎任何建议
async getItems(): Promise < any > {
try {
let url = `https://vpce-[id].execute-api.ap-southeast-2.vpce.amazonaws.com/prod/items`
const response = await axios.get(url, {
headers: {
'Authorization': `Bearer ${token}`,
'x-apigw-api-id': `[api-id]`
}
});
return response.data;
} catch(error) {
console.log(error);
throw error;
}
}
【问题讨论】:
标签: node.js amazon-web-services aws-lambda axios