facebook twitter hatena line google mixi email

Gcp/Firebase/CloudFunctions/request

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

getでのrequest

functions/index.js

exports.log1 = functions.https.onRequest((request, response) => {
  const errorlog = request.query['errorlog']
  console.error(errorlog);
  response.send("Hello from Firebase!log");
});

ttps://us-central1-unity-xxxxx.cloudfunctions.net/log1?errorlog=hoge

postでのrequest

functions/index.js

exports.log1 = functions.https.onRequest((request, response) => {
  if (request.method !== 'POST') {
    response.status(405).send('Method Not Allowed');
    return;
  }
  const errorlog = request.body.errorlog;
  console.error(errorlog);
  response.status(200).send(errorlog);
});