When I am trying to update my document in firebase I got an error like my topic. After I upload my image to firebase storage and I need to update the download link to my Users collection.(I used Redux-Saga for this process)
export function* uploadProfile(action) {
console.log(action);
const filePath = action.data.filePath;
const fileName = action.data.fileName;
const userID = action.data.userID;
try {
const uploadProfile = yield call(uploadFileFireBase, filePath, fileName)
if (uploadProfile) {
try {
const updateProfile = yield call(updateUserFirebase, userID, uploadProfile)
if (updateProfile) {
}
} catch (error) {
console.log(error)
}
}
} catch (error) {
console.log(error)
}
}
async function uploadFileFireBase(filePath, fileName) {
const reference = storage().ref(fileName);
await reference.putFile(filePath.toString());
// console.log("Download URL:" + url)
return await storage().ref(fileName).getDownloadURL();
}
/*
Update User Data
*/
function updateUserFirebase(uploadProfile, userID) {
return firestore()
.collection('Users')
.doc(userID)
.update({
profileImage: uploadProfile,
})
.then((data) => {
console.log('User updated!');
return data;
});
}
I spent hours and hours trying to make this write and I couldn't. So I really really need your help with this university project. Thank you very much for your time.❤️❤️