facebook twitter hatena line email

「Gcp/CloudFunctions/基本」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(公開する関数作成)
行21: 行21:
 
トリガーのurlにアクセス
 
トリガーのurlにアクセス
 
ttps://asia-northeast1-indigo-computer-xxx.cloudfunctions.net/function-1
 
ttps://asia-northeast1-indigo-computer-xxx.cloudfunctions.net/function-1
 +
 +
以下がhtmlに表示される
 +
Hello World!

2022年11月6日 (日) 21:43時点における版

公開する関数作成

  1. CloudFunctionsを選択
  2. "関数の作成"ボタンをクリック
  3. リージョンに、asia-northeast1を選択
  4. "未認証の呼び出しを許可"にチェック

index.js

exports.helloWorld = (req, res) => {
  let message = req.query.message || req.body.message || 'Hello World!';
  res.status(200).send(message);
};

package.json

{
  "name": "sample-http",
  "version": "0.0.1"
}

トリガーのurlにアクセス ttps://asia-northeast1-indigo-computer-xxx.cloudfunctions.net/function-1

以下がhtmlに表示される

Hello World!