Created
February 14, 2020 08:59
-
-
Save Kaz-su/025476699b733d0d4eb12110cb4d06b3 to your computer and use it in GitHub Desktop.
Cloud Functions で HTTP POST リクエストを受けて Firestore に書き込む例
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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