Is it possible to run a query in my main.ts file with another ts file and then pull the result of the query into another file? If so, how can this be achieved?
Here is an example from my main.ts file:
async function getAllTips() {
const tips: any = []; // I want to access the "tips" array in another ts file
try {
const snapshot = await ref
.child("tips")
.orderByChild("cont")
.startAt(1)
.endAt(5)
.get();
if (snapshot.val()) {
for (let key in snapshot.val()) {
let value = snapshot.val()[key];
tips.push(value.get("tips"));
}
}
} finally {
return tips;
}
}
async function asyncForArray(array,callback){
for(let i=0;i<array.length;i++){
await callback(array[i],i);
}
}
async function asyncFor(obj,callback){
for(let key in obj){
await callback(
obj[key],key
);
}
}
export {
getAllTips
}
How can I access the "tips" array in another file? Any suggestions would be greatly appreciated!