[英]How to handle the AWS lambda function error in nodejs
我正在使用節點 js 從服務器獲取 HTTPS 響應。 響應包含超過 6291556 個字節當我執行這個函數時,我得到了以下異常。 有沒有最好的方法來處理錯誤
{
"errorMessage": "Response payload size exceeded the maximum allowed payload size (6291556 bytes).",
"errorType": "Function.ResponseSizeTooLarge"
}
示例代碼
var res = await beResult(event.id);
const response = {
statusCode: 200,
body: res,
};
return response;
};
async function beResult(id) {
const url = "https://api.com/request/";
const params = {
method: "GET",
mode: "cors",
headers: {
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
"Content-Type": "application/json",
}
};
const urlId= url + id;
return await fetch(urlId, params).then(res => res.json())
.then(json => { return json;});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.