Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function collectres () {
- var store ='';
- var docRef = db.collection("cities").doc("SF");
- docRef.get()
- .then(function (doc) {
- if (doc.exists) {
- console.log("Document data:", doc.data());
- store = doc.data();// when referenced outside, it doesnt hold anything.
- } else {
- // doc.data() will be undefined in this case
- console.log("No such document!");
- }
- })
- .catch(function (error) {
- console.log("Error getting document:", error);
- });
- return store; // returns nothing and seems to not notice the assignment.
- }
- user.CollectRes(function(store){
- console.log(store.name);
- name =store.name;
- console.log(name);
- // this.setState({name:store.name});
- });
- console.log(name); // want to be able to reference this outside the callback function. So i can display it on the page.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement