TL;DL 🗒
- Lambda で 配列の要素を順番にfetchし、成功したら結果をレスポンスに詰めて返す
- Promise.all を使うと簡単
成果物 🎉
レスポンスはこんな感じ
{
"statusCode": 200,
"body": [
"<!DOCTYPE html>\n\n<html>\n<head>\n <title>Transit List</title>\n <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css\" integrity=\"sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb\" crossorigin=\"anonymous\"> </link>\n</head>\n<body>\n<div class=\"container\">\n <h1>TransitList from Google Calendar</h1>\n <a href=\"https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=force&client_id=454990322241-tfegbc9eltda89sg1ndciijdduidpd3r.apps.googleusercontent.com&redirect_uri=https://transitlist.herokuapp.com/transitlist&response_type=code&scope=https://www.googleapis.com/auth/calendar%20https://www.googleapis.com/auth/calendar.readonly\"><button type=\"button\" class=\"btn btn-primary\">Login</button></a>\n <br />\n <br />\n <p>注意点</p>\n <ul>\n <li>Calendarには\"【駅名】訪問先\"のフォーマットで記録してください。</li>\n <li>【駅名】はYahoo乗り換え案内で出てくる正確な駅名を記録してください。</li>\n <li>開始時間を必ず入れてください(終日を選択すると無視します。)</li>\n <li>その日の最初の訪問先の前に交通費が発生する最初の駅も記録してください。</li>\n <li>その日の最後の訪問先の後に交通費が発生する最後の駅も記録してください。</li>\n </ul>\n</div>\n<script src=\"https://code.jquery.com/jquery-3.2.1.slim.min.js\" integrity=\"sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN\" crossorigin=\"anonymous\"></script>\n<script src=\"https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js\" integrity=\"sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh\" crossorigin=\"anonymous\"></script>\n<script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js\" integrity=\"sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ\" crossorigin=\"anonymous\"></script>\n</body>\n</html>"
]
}