Lesson 5 - Firebase - Web
Creating our own API with Firebase
How to structure your data and more about Firebase:
https://firebase.google.com/docs/database/rest/structure-data
Using Firebase with a REST API
https://firebase.google.com/docs/database/rest/save-data
Other Firebase auth endpoints
https://firebase.google.com/docs/reference/rest/auth/
Setup
Register with your email/pass to start writing/reading to our Firebase App. You don't need to use your real credentials. Use any email/pass values.
For the steps below, you will need an HTTP client to test these API calls, there are many out there. Such as Postman, Paw, Insomnia. Choose whichever you prefer.
STEP 1. SEND A JSON PAYLOAD TO THIS ENDPOINT WITH THE DETAILS BELOW.
POST
Payload
You will get a response back, that contains a JSON payload. Take note of the value of the keyidToken
andlocalId
ThelocalId
is your userspace token. So be sure to include it with every request.
STEP 2. WRITING TO THE FIREBASE DB WITHIN YOUR USERSPACE
POST
Payload
Take note to replace the values in <> with dynamic values you obtain in step 1.
STEP 3. READING THE DATA FROM THE FIREBASE DB
GET
You should see the message you wrote to the database in step 2.
Calling the Firebase API with React
Go to the folder where you cloned down the bootcamp-web-project repo - https://github.com/ProDigi-Developement/bootcamp-web-project/
Checkout the branch firebase
- git checkout firebase
In src/utils/api.js
replace the username and password variables with your own from the steps above.
Last updated