Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. console.log("Starting")
  2. var firebase = require("firebase/app");
  3.  
  4. // Add the Firebase products that you want to use
  5. require("firebase/auth");
  6. require("firebase/firestore");
  7. require('firebase/database');
  8.  
  9.  
  10. console.log("Firebase was imported")
  11.  
  12. var firebaseConfig = {
  13. apiKey: ...,
  14. authDomain: ...,
  15. databaseURL: ...,
  16. projectId: ...,
  17. storageBucket: ...,
  18. messagingSenderId: ...,
  19. appId: ...
  20. };
  21. // Initialize Firebase
  22.  
  23. console.log("Firebase initializition")
  24. firebase.initializeApp(firebaseConfig);
  25.  
  26. console.log("connect to db")
  27. var database = firebase.database();
  28.  
  29.  
  30. function writeApartmentData(apartmentId, street_, number_, floor_, door_) {
  31. firebase.database().ref('apartments/' + apartmentId).set({
  32. street: street_,
  33. number: number_,
  34. floor: floor_,
  35. door: door_
  36.  
  37. });
  38. }
  39.  
  40. console.log("write apartment data")
  41. writeApartmentData(1, "calle amalia", 18, 3, "B")
  42.  
  43.  
  44.  
  45. console.log("End");
  46.  
  47. luca@luca-VirtualBox:~/PisoReview$ node index.js
  48. Starting
  49. Firebase was imported
  50. Firebase initializition
  51. connect to db
  52. write apartment data
  53. End
  54. [2019-06-16T17:52:19.193Z] @firebase/database: FIREBASE WARNING: set at /apartments/1 failed: permission_denied
  55. (node:10870) UnhandledPromiseRejectionWarning: Error: PERMISSION_DENIED: Permission denied
  56. at /home/luca/PisoReview/node_modules/@firebase/database/dist/index.node.cjs.js:13139:33
  57. at exceptionGuard (/home/luca/PisoReview/node_modules/@firebase/database/dist/index.node.cjs.js:695:9)
  58. at Repo.callOnCompleteCallback (/home/luca/PisoReview/node_modules/@firebase/database/dist/index.node.cjs.js:13130:13)
  59. at /home/luca/PisoReview/node_modules/@firebase/database/dist/index.node.cjs.js:12907:19
  60. at /home/luca/PisoReview/node_modules/@firebase/database/dist/index.node.cjs.js:12078:17
  61. at PersistentConnection.onDataMessage_ (/home/luca/PisoReview/node_modules/@firebase/database/dist/index.node.cjs.js:12111:17)
  62. at Connection.onDataMessage_ (/home/luca/PisoReview/node_modules/@firebase/database/dist/index.node.cjs.js:11394:14)
  63. at Connection.onPrimaryMessageReceived_ (/home/luca/PisoReview/node_modules/@firebase/database/dist/index.node.cjs.js:11388:18)
  64. at WebSocketConnection.onMessage (/home/luca/PisoReview/node_modules/@firebase/database/dist/index.node.cjs.js:11289:27)
  65. at WebSocketConnection.appendFrame_ (/home/luca/PisoReview/node_modules/@firebase/database/dist/index.node.cjs.js:10892:18)
  66. (node:10870) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
  67. (node:10870) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  68. ^C
  69. luca@luca-VirtualBox:~/PisoReview$ ^C
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement