【发布时间】:2017-11-05 10:27:42
【问题描述】:
我在我的应用中使用 React Native 和 Firebase。我突然开始收到这个错误:
SyntaxError: Unexpected end of JSON input.
at doWrite(_stream_writable.js)
at Promise.resolve.then.then.then.catch.then.message
在我的反应包装器中它指向这个代码:
onProfilesChange = async (snap) => {
var allProfilePromises = []
snap.forEach((child) => {
var profileId = child.val().profileId
var alreadyAdded = this.state.profiles.some(x => x.id === profileId)
if (alreadyAdded === false) {
var profilePromise = this.registerOnProfileChanges(profileId)
allProfilePromises.push(profilePromise)
}
})
await Promise.all(allProfilePromises)
var profileCount = snap.numChildren()
this.setState({ profiles: this.state.profiles, loading: false, profileCount: profileCount })
if (profileCount <= 0) {
this.getUserName()
}
}
在调用 componentMount 时正在运行。现在错误很清楚,但我不知道为什么会产生它,也不知道如何通过它。这段代码已经运行了几个月,我没有对其进行任何更改。
提前致谢。
【问题讨论】:
标签: android firebase react-native