LANG SELRCT

Apps Script Reference  (Create: Create new Spreadsheet | Create new Apps Script

Friday, February 22, 2019

AWS LambdaでAPI Gatewayのクエリパラメータを取得したい


API Gatewayで、endpoint の末尾に ?key=value 等のパラメータをつけて

API endpoint:
https://API_ID.execute-api.us-east-1.amazonaws.com/default/FUNCTION_NAME?key=value


Lambda Function の中で

event['queryStringParameters']

と書くと

{key: value}

と取得できる


Lambda Functionのコード

index.js
exports.handler = async (event) => {
    let param = event['queryStringParameters'];
    const response = {
        body: JSON.stringify(param),
    };
    return response;
};
意訳
この機能がやること
パラメータを取得する
返すオブジェクトを作って
返す本文はパラメータをJSONにしたもの

返す



関連記事


Latest post

Creating a template copier app in Google Apps Script

Introduction This article will show you a template copier application in Google Apps Script.  This application will automatically copy a t...