修正 > デプロイを繰り返すのはツライので、ローカルで実行できる環境を整えたときのメモ
Firebase CLIインストール
参考
* Testing Functions Locally with the Cloud Functions Shell
* Firebase Documentation - ローカルでの関数の実行
* npm - request
上記のブログなどを参考に、Firebase CLIのバージョンをv3.11.0に上げてコマンドを試した。
experimental:functions:shell [options] launch full Node shell with emulated functions
実行したところエラー出たので言われるがままv6.9.1にして再実行
functions: Cannot start emulator. Please use Node version v6.9.1, you have v7.3.0
またエラーとりあえずv6.11.5にして試してみる…
Node.js v6.11.x or greater is required to run the Emulator!
やっとローカル実行できるようになった
$ sudo firebase experimental:functions:shell
i functions: Preparing to emulate functions.
✔ functions: test
firebase >
HTTPS関数の実行
実行したかったのはHTTPS関数だったので、こちらを参考に。
Firebase Documentation - HTTPS 関数を呼び出す
なので、testというファンクションを実行する場合はこうなる。
test.get()
下記のようにGETパラメータだけ付けて実行したいのだが…例の一覧には記載はなく。
https://us-central1-xxxxxxx.cloudfunctions.net/test?key=value
シェルで HTTPS 関数を呼び出す場合、使用方法は request NPM モジュールと同じですが
と書いてあったので、次のように実行したら思ったように動作した。
test.get({qs: {key: 'value'}})