:clipboard: Angular with Firebase Functions and express to access Cloud Firestore realtime database
Create Service Account
/Node.js (default option)then Generate new private key
that adds a json file to the user’s PC. The path to this access key file is referenced in the express server index.ts
filenpm i
ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files./functions
and run npm i
then npm run serve
to install backend dependencies, create build file and start up Functions emulatorlocalhost../api/databaseKey
the realtime database value will be displayedng build
to build the project. The build artifacts will be stored in the dist/
directory. Use the --prod
flag for a production build.ng update
to update Angularindex.ts
function to retrieve value from Firebase realtime database for key supplied
// get value corresponding to key supplied
app.get("/database_ref", (request, response) => {
const db = admin.database();
const ref = db.ref("database_ref");
ref.once("value").then((value) => {
response.send(value);
})
.catch((err) => console.error(err));
});