I have a collection of firestore documents which contain an array of reference objects, referencing documents found in another firestore collection. When i attempt to fetch a document and convert it to JSON data i get an error : "TypeError: Converting circular structure to JSON". The issue seems to be with the type of the firestore reference? Im new to typescript and am not sure what the issue is as everything works when i exclude the array of references. (Also the references are not actually circular, they reference completely separate documents that are not related)
Here is the code used to get the document
interface PlaylistData {
name: String
description: String
coverImage: String
tracks: [FirebaseFirestore.DocumentReference]
}
export const getPlaylist = functions.https.onRequest((request, response) => {
admin.firestore().collection("playlists")
.doc('test').get()
.then(function (snapshot){
let data = <PlaylistData>snapshot.data()
console.log(data)
response.send(data)
})
.catch(error => {
console.log(error)
response.status(500).send("ERROR")
});
});