I have an Firestore, that i used in the previous project, but now i need to use this same Firestore in another project, so I try to connect to my Firestore in it like that:
const firebaseCredentials = {
apiKey: "some",
authDomain: "some",
databaseURL: "some",
projectId: "some",
storageBucket: "some",
messagingSenderId: "some",
appId: "some"
}
@Injectable()
export class FirestoreProvider {
public db: admin.firestore.Firestore;
constructor() {
this.db = admin.initializeApp(firebaseCredentials).firestore();
}
}
this provider I inject in one of my service like this:
@Injectable()
export class AppService {
constructor(
private readonly firestore: FirestoreProvider
) {}
getHello(): any {
const snap = this.firestore.db
.collection("books")
.get();
return snap;
}
}
and now i have a problem, when i try to run this function above, my console throw me this error:
[Nest] 22700 - 21.09.2021, 18:43:47 [ExceptionsHandler] Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information. +29285ms
can someone tell me what I'm doing wrong? in the previous project everything work fine with this same credentials, thanks for any help!