Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fetch("https://fir-6e9c1-default-rtdb.europe-west1.firebasedatabase.app/Books.json")
- .then((res) => {
- return res.json();
- })
- .then((response) => {
- for (const key in response) {
- console.log(response[key]);
- }
- })
- .catch(err => {
- console.error(err);
- })
- fetch("https://fir-6e9c1-default-rtdb.europe-west1.firebasedatabase.app/Books.json", {
- method: "PUT",
- headers: {
- "Content-Type": "application/json"
- },
- body: JSON.stringify({
- Author: 'John Doe',
- 'Books Genre': 'Scifi',
- Title: 'Demo book'
- })
- })
- .then((res) => {
- if (res.ok) {
- console.log("PUT request was successful.");
- } else {
- console.error("PUT request failed.");
- }
- })
- .catch(err => {
- console.error(err);
- });
Advertisement
Add Comment
Please, Sign In to add comment