0
0

More than 1 year has passed since last update.

GASの doGet と doPost のイベントオブジェクトの型定義

Posted at

doGet(e)doPost(e) の引数eの型定義。
ブラウザでサクッと済ませたい時用。

tl;dr

typedef
/**
 * @typedef ApiEventGet
 * @property {string} queryString
 * @property {Object<string, string>} parameter
 * @property {Object<string, string[]>} parameters
 * @property {number} contentLength
 */

/**
 * @typedef _PostData
 * @property {number} length
 * @property {string} type
 * @property {string} contents
 * @property {string} name
 */

/**
 * @typedef ApiEventPost
 * @property {string} queryString
 * @property {Object<string, string>} parameter
 * @property {Object<string, string[]>} parameters
 * @property {number} contentLength
 * @property {_PostData} postData
 */

usage

api.gs
/**
 * @param {ApiEventGet} e
 */
function doGet(e) {
  const id = e.parameters.id
}

/**
 * @param {ApiEventPost} e
 */
function doPost(e) {
  const data = JSON.parse(e.postData.contents)
}

参照

Web Apps  |  Apps Script  |  Google Developers

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0