Skip to content

Instantly share code, notes, and snippets.

@Kaz-su
Created February 14, 2020 08:59
Show Gist options
  • Save Kaz-su/025476699b733d0d4eb12110cb4d06b3 to your computer and use it in GitHub Desktop.
Save Kaz-su/025476699b733d0d4eb12110cb4d06b3 to your computer and use it in GitHub Desktop.
Cloud Functions で HTTP POST リクエストを受けて Firestore に書き込む例
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
var fireStore = admin.firestore();
exports.helloWorld = functions.https.onRequest((request, response) => {
if (request.method !== 'POST') {
response.status(405).send('method not allowed');
return;
}
fireStore.collection("test").doc("docTest").set({ hoge: "fuga" });
response.status(200).send("Hello from Firebase!");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment