AWS Lambda 関数の呼び出し方法
AWS ドキュメント参照
https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/invoking-lambda-functions.html
AWS Lambda 関数のリクエスト
var xhr = new XMLHttpRequest();
xhr.open('GET','https://ganyf52nbe.execute-api.ap-northeast-1.amazonaws.com/dev/compare-yourself/all');
xhr.onreadystatechange = function(event) {
console.log(event.target.response);
}
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send();
> 結果 OK chrome で表示される
all のケース
var xhr = new XMLHttpRequest();
xhr.open('GET','https://ganyf52nbe.execute-api.ap-northeast-1.amazonaws.com/dev/compare-yourself/all');
xhr.onreadystatechange = function(event) {
console.log(JSON.parse(event.target.response));
}
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send();
single のケース
var xhr = new XMLHttpRequest();
xhr.open('GET','https://ganyf52nbe.execute-api.ap-northeast-1.amazonaws.com/dev/compare-yourself/single');
xhr.onreadystatechange = function(event) {
console.log(JSON.parse(event.target.response));
}
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send();
> 結果 一つのデータが表示される