Yash Choksi:
I have done this Code it shows console output properly on writing console.log() method but it doesn't store code to my database.
It doesn't shows any other errors but don't store data to database, so please tell me what to change to make to store to database.
Here is the code :
import React, { Component } from 'react';
var firebase = require('firebase');
var uuid = require('uuid');
var config = {
apiKey: "AIzaSyDf5i7ULK0JTWYM3_X3wMQPUaaLPRYExC0",
authDomain: "usurvey-419eb.firebaseapp.com",
databaseURL: "https://usurvey-419eb.firebaseio.com",
projectId: "usurvey-419eb",
storageBucket: "usurvey-419eb.appspot.com",
messagingSenderId: "395101866940"
};
firebase.initializeApp(config);
class Usurvey extends Component {
constructor(props)
{
super(props);
this.state={
uid:uuid.v1(),
firstName: '',
lastName:''
};
this.submitData=this.submitData.bind(this);
this.inputData=this.inputData.bind(this);
}
submitData()
{
document.write({uid: this.state.uid,firstName:this.state.firstName,lastName:this.state.lastName});
// document.write(this.state.firstName);
// document.write(this.state.lastName);
firebase.database().ref('Newdata/'+this.state.uid).set({
firstName: this.state.firstName,
lastName: this.state.lastName
});
}
inputData(event)
{
var firstName = this.refs.name1.value;
var lastName = this.refs.name1.value;
console.log(this.state.uid,this.state.firstName,this.state.lastName);
this.setState({firstName:firstName, lastName:lastName});
console.log(this.state.firstName,this.state.lastName);
}
render(){
return(
);
}
}
export default Usurvey;
Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE