Skip to content
Advertisement

Firebase not working on script but on main html it does (Javascript)

after pasting the given data of my database, doing

JavaScript

retrieves correctly the data and its shown as i want, but making a function on a index.js

JavaScript

gives me this error Uncaught ReferenceError: data is not defined at extend (index.js:59) at index.js:61

I dont get why it would work outside the function and not inside, given that window.db is a global instance, i’ve tried a couple of ways differently without success, would somebody help me? 🙂

Advertisement

Answer

The variable data is not defined in the extend() function (unless it’s some global variable, extend()). You’ll get better results if you refactor your code like so:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement