I have been able to resolve the promise that returned me
Promise {<pending>}
__proto__: Promise
[[PromiseStatus]]: "resolved"
[[PromiseValue]]: Array(7)
But this time I had the problem when extracting the variable, in this case it turned out, the reason I want to extract it is to store it in a react useState.
This is the code
const fsdasfda = db
.collection("socios")
.where("activity", "==", "true")
.orderBy("num")
.get()
.then(function (query) {
const array = [];
query.forEach(function (doc) {
const data = doc.data();
array.push(data);
});
return array;
})
.then((result) => {
console.log(result);
});
console.log(fsdasfda);
const [unidades, setUnidades] = useState(HERE);
console.log (result); it returns the data as I want to pass to the use state. console.log (fsdasfda); the promise returns
As I mentioned earlier I want to pass the RESULT value to the useState
I try this but it still appears as a promise.
fsdasfda.then((data) => console.log(data));
docsproperty needs to be accessed in order to get the full list of documents from the query. firebase.google.com/docs/reference/js/… - dzv3useState()is to have its parent component performs the async task and pass the result to it as a prop. - hangindev.com