Issue
In my Ionic app, I apply FirebaseX plugin (https://github.com/dpa99c/cordova-plugin-firebasex) and use its method fetchDocumentInFirestoreCollection to access a document from my Firestore (assume the document does exist properly). It successfully passes the success callback function inside the method but the returned document object is never accessed. I don't know how to access it actually. Here are my two used approaches to access:
await this.firebase.fetchDocumentInFirestoreCollection(
someDocID,
'someCollection',
() => {
console.log('fetchFirestoreCollection successfully'); // this can be printed
},
error => {
console.error('error in fetchFirestoreCollection', error);
}
).then(
doc => {
// Not enter this block ever
console.log(doc);
}
);
const doc = await this.firebase.fetchDocumentInFirestoreCollection(
someDocID,
'someCollection',
() => {
console.log('fetchFirestoreCollection successfully'); // this can be printed
},
error => {
console.error('error in fetchFirestoreCollection', error);
}
);
But both of these two cannot access the returned document. How should I do?
Thank you.
Solution
In the @ionic-native/firebase-x/ngx/index.d.ts, change line 437 from
fetchDocumentInFirestoreCollection(documentId: string, collection: string, success: () => void, error: (err: string) => void): Promise<any>;
to
fetchDocumentInFirestoreCollection(documentId: string, collection: string, success: (value: object) => void, error: (err: string) => void): Promise<any>;
Answered By - M. G. Lincoln
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.