Create first Firebase cloud function
$ npm install -g firebase-tools
$ firebase login
$ firebase init
select Functions
use exist project or new
const functions = require('firebase-functions');
// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
// exports.helloWorld = functions.https.onRequest((request, response) => {
// response.send("Hello from Firebase!");
// });
เป็น
const admin = require('firebase-admin');
const functions = require('firebase-functions);
admin.initializeApp(functions.config().firebase);
exports.helloWorld = functions.https.onRequest((request, response) => {
response.send("Hello from Firebase!");
});
$ firebase deploy --only functions
หรือ
$ npm run deploy
https://us-central1-<project_id>.cloudfunctions.net/helloWorld