I've been working on a function that should return an array of strings, but for some reason, it's not returning as expected:
let returnArr = [];
export async function snapshotToArray() {
const db = firebase.firestore();
db.collection('userinfo').get().then(querySnapshot => {
querySnapshot.forEach(documentSnapshot => {
let id = documentSnapshot.id;
returnArr.push(id).toString();
});
console.log(returnArr);
return returnArr;
});
}
The function that calls the Array creation Function is this one:
export async function getStaticPaths() {
const paths = await snapshotToArray();
return {
paths,
fallback: false
}
}
However, despite what the console shows, the function doesn't seem to return the expected value.
As a result, I'm encountering this error message:
Error: Invalid `paths` value returned from getStaticPaths in /user/[name].
`paths` must be an array of strings or objects of shape { params: [key: string]: string }
I have tried various methods to resolve this issue without success. Any assistance would be greatly appreciated.