【发布时间】:2021-11-05 12:49:19
【问题描述】:
我尝试从 Firebase 中删除图像。我认为问题在于我没有得到 URL。刷新平面列表后,我收到以下警告:
"可能的未处理承诺拒绝 (id: 1): 对象 {}"
仅当我在删除项目后刷新平面列表时才会显示此警告。
“downloadURL”是我将图像上传到 Firebase 时下载的 URL。是我应该尝试获取的那个 URL 还是我错了?
export function deleteBoards(item) {
return (dispatch, getState) => {
return new Promise((resolve, reject) => {
firebase
.firestore()
.collection('coachboards')
.doc(auth().currentUser.uid)
.collection('userCoachboards')
.doc(item.id)
.delete()
.then((snapshot) => {
//Here I try to delete the image from firebase storage
storage()
.refFromURL(snapshot.data().downloadURL.url)
.delete()
.then(function () {
resolve();
})
.catch(function (error) {console.log(error)});
})
.catch(() => {
reject();
});
});
};
}
更新结果✅
export function deleteBoards(item) {
return (dispatch, getState) => {
return new Promise((resolve, reject) => {
firebase
.firestore()
.collection('coachboards')
.doc(auth().currentUser.uid)
.collection('userCoachboards')
.doc(item.id)
.delete()
.then(() => {
//Here I try to delete the image from firebase storage
storage()
.refFromURL(item.downloadURL)
.delete()
.then(() => {
resolve();
})
.catch(error => {
reject();
});
})
.catch(() => {
reject();
});
});
};
}
【问题讨论】:
标签: firebase react-native firebase-storage