It is a service offered by Google, which acts as an API for our database, which isn't actually a database.
Create a project on Firebase. Select real-time database, and create a new real-time database, with test settings. This will give us an API URL to which we can send and receive data from.
To use it in thee fetch method in our React app, we will use the URL with a /movies.json, which will create a new node called movies , and the .json in the end is a standard for Google Firebase real-time db, through which we fetch and post data.
We need to set the method to POST, and use JSON.stringify() to convert the JavaScript object into a JSON object so that it can be sent as the POST body. We also set the headers here.
Of course, we need to add the async and await keywords since "POSTing" data to the server is also an asynchronous task.
const fetchMovieHandler = async() => {
const response = await fetch('https://movie-db.firebase.io/movies.json');
const data = await response.json();
const loadedMovies = [];
for (const key in data) {
loadedMovies.push({
id: data[key].id,
title: data[key].title,
releaseDate: data[key].releaseDate,
openingText: data[key].openingText
})
}
//iterate over loadedMovies with .map() and set state of movies to each movie
//in the loadedMovies array.
}