【发布时间】:2022-01-20 22:16:55
【问题描述】:
com.google.firebase.functions.FirebaseFunctionsException:响应不是有效的 JSON 对象。
exports.loadVideos = functions
.region('asia-south1')
.https.onRequest(async (req, res) => {
let uid = []
const subscribers = await db
.collection(SUBSCRIPTIONS_COLLECTION)
.doc('05piDSvu5mNxHOn2yKpnL2V322r1')
.get()
subscribers.data().subsBy.forEach((s) => {
uid.push(s.userId)
})
return db
.collection('videos')
.where('userId', 'not-in', uid)
.get()
.then((snapshot) => {
if (snapshot.empty) {
return res.status(404).send({
error: 'Unable to find the document',
})
}
let items = []
snapshot.docs.forEach((doc) => {
items.push(doc.data())
})
return res.status(200).send(items)
})
.catch((err) => {
console.error(err)
return res.status(404).send({
error: 'Unable to retrieve the document',
err,
})
})
})
无法找出问题,尝试使用单个文本时效果很好,但我需要整个集合。
【问题讨论】:
标签: android firebase google-cloud-functions