Closed yspanchal closed 5 years ago
Is it possible to wait till document is received in componentdidmount ?
Isfirst = () => { var value = undefined; dB.findOne({'isfirst': true}, function (err, doc){ console.log(doc) value = doc }) return value }
Componentdidmount() { var value = this.Isfirst(); console.log(value); }
I did not understand your question, but you can use db.findAsync, which returns a promise
db.findAsync
@antoniopresto can please give me an example of dB.findAsync how can I use it ?
Thank you.
Is it possible to wait till document is received in componentdidmount ?
Isfirst = () => { var value = undefined; dB.findOne({'isfirst': true}, function (err, doc){ console.log(doc) value = doc }) return value }
Componentdidmount() { var value = this.Isfirst(); console.log(value); }