Skip to content

Instantly share code, notes, and snippets.

View fredriccliver's full-sized avatar
🧭
To the north

Fredric Cliver fredriccliver

🧭
To the north
View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
/>
var firebaseConfig = {
// ...
}
// Initialize Firebase
firebase.initializeApp(firebaseConfig)
const db = firebase.firestore()
// adding function (UI)
const list = document.querySelector("ul")
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
},
"storage": {
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
},
"firestore": {
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
},
"emulators": {
const functions = require("firebase-functions")
exports.retrieve = functions.https.onCall((req, res) => {
// Response.send("This is Data")
return "This is data"
})
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Welcome to Firebase Hosting</title>
<!-- update the version number as needed -->
<script defer src="/__/firebase/7.19.1/firebase-app.js"></script>
<!-- include only the Firebase features as you need -->
let functions = firebase.functions()
functions.useFunctionsEmulator('http://localhost:5001')
let btn = document.querySelector("#btn-get-data")
let label = document.querySelector("#label")
let retrieveData = functions.httpsCallable("retrieve")
btn.addEventListener("click", (e) => {
retrieveData()
const functions = require("firebase-functions")
const express = require("express")
const app = express()
// my routings
const apiRoute = require("./api")
// add routes to the express app.
app.use("/api", apiRoute)
const router = require("express").Router()
router.get("/api/user/data", (req, res) => {
res.send(`this is /api/user/data`)
})
router.get("/api/data", (req, res) => {
res.send(`this is /api/data`)
})