1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have 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

1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?