【发布时间】:2016-12-20 21:00:03
【问题描述】:
我在运行我的 react-native 移动应用时收到此警告。 我尝试将带有 react-native-image-picker 的照片上传到 firebase(在存储中),并将这张照片的 url 保存在 firebase(数据库)中。上传成功,但是当程序尝试将 url 保存在数据库中时,应用程序会发出警告:“可能未处理的承诺拒绝:找不到变量:侦听器”。 以下是我的代码:
ImagePicker.showImagePicker(options, (response) => {
let filePath = response.path;
let fileName = this.props.imageName;
let rnfbURI = RNFetchBlob.wrap(filePath);
Blob
.build(rnfbURI, { type : 'image/png;'})
.then((blob) => {
// upload image using Firebase SDK
this.props.bdd.storage()
.ref('images')
.child(fileName)
.put(blob, { contentType : 'image/jpg' })
.then((snapshot) => {
console.log('Uploaded', snapshot.totalBytes, 'bytes.');
console.log(snapshot.metadata);
console.log('downlo='+snapshot.metadata.downloadURLs[0]);
var ref = this.props.bdd.database().ref('promotions/'+ fileName);
alert(snapshot.metadata.downloadURLs[0]);
ref.update({
image_url:snapshot.metadata.downloadURLs[0]
});
}).catch(function(error) {
console.error('Upload failed:', error);
});
})
});
}
【问题讨论】:
-
什么是
listeners?
标签: reactjs react-native promise warnings