import * functions form "firebase-functions"; import * express from "express"; const app = express(); app.use(express.json()); app.use(express.urlencoded({ extended: true })); app.use(cors({ origin: true })); const collectionName = "sample"; //ここを書き換える app.get("/", (res, req) => { return res.status(200).("Hello world"); }); export sample = functions.http.onRequest();
Collection一覧の取得
app.get("/", (res, req) => { return db.collection(collectionName).get().then((doc) => { const data: any[] = []; doc.forEach((d) => { data.push(d); }); return res.status(200).(data); }); });