mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Update with-firebase-auth example (#5742)
- The with-firebase-auth example won't run unless a database with proper rules is created first. - Add a small error callback to addDbListener to help with debugging if someone's database connection doesn't work.
This commit is contained in:
parent
d6d9dd1e42
commit
b63487c331
|
@ -29,6 +29,7 @@ Set up firebase:
|
||||||
- Get your authentication credentials from the Firebase console under *authentication>users>web setup*. It will include keys like `apiKey`, `authDomain` and `databaseUrl` and it goes into your project in `credentials/client.js`.
|
- Get your authentication credentials from the Firebase console under *authentication>users>web setup*. It will include keys like `apiKey`, `authDomain` and `databaseUrl` and it goes into your project in `credentials/client.js`.
|
||||||
- Copy the `databaseUrl` key you got in the last step into `server.js` in the corresponding line.
|
- Copy the `databaseUrl` key you got in the last step into `server.js` in the corresponding line.
|
||||||
- Back at the Firebase web console, go to *authentication>signup method* and select *Google*.
|
- Back at the Firebase web console, go to *authentication>signup method* and select *Google*.
|
||||||
|
- Create a database in the "Database" tab and select the realtime database. Then go to "rules" and set up your write, read rules. Examples can be found here: https://firebase.google.com/docs/database/security/quickstart#sample-rules
|
||||||
|
|
||||||
Install it and run:
|
Install it and run:
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,8 @@ export default class Index extends Component {
|
||||||
firebase.database().ref('messages').on('value', snap => {
|
firebase.database().ref('messages').on('value', snap => {
|
||||||
const messages = snap.val()
|
const messages = snap.val()
|
||||||
if (messages) this.setState({ messages })
|
if (messages) this.setState({ messages })
|
||||||
|
}, (error) => {
|
||||||
|
console.error(error)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue