I am trying to update array of images but all i got its just amtpy arrayin appwrite but my Json data has Array of images And Theres no errors photos : [ "https://appwrite.homesapp.ru/v1/storage/buckets/6555e8fcbfa39471492a/files/magazinesScroll-image-1--1646138978/view?project=65140369acf5f3040759", "https://appwrite.homesapp.ru/v1/storage/buckets/6555e8fcbfa39471492a/files/magazinesScroll-image-0--1646138978/view?project=65140369acf5f3040759" ]
Can you show the code?
yeah
const { mutate: updateData, reset, } = useMutation({ mutationFn: async (newGalData: GalaryScrollBlock | null | undefined) => { console.log(newGalData) if (newGalData) { // console.log(newGalData) const dataId = newGalData.map((item) => { return item.$id })
const filteredVals = newGalData.map((item) => {
// console.log(itemPhoto)
const newData: any = {
mainPhoto: item.mainPhoto,
photos: item.photos,//item.photos
// photos:
price: Number(item.price),
features: item.features,
description: item.description || '',
status: item.status,
location: item.location
}
return newData
})
console.log(filteredVals)
// Promise.all(filteredVals.map())
filteredVals.map((item, i) => { return api.updateGalaryScroll(filteredVals[i], dataId[i]) })
// .then(alert);
// console.log(filteredVals)
}
},
onSuccess: () => {
alert('Success')
setTimeout(reset, 2000)
},
onError: (error) => {
console.log(error)
}
})
val.posterPhotos.map(async (valImageFile: File, i: number) => {
const fileId = magazinesScroll-image-${i}-${hash}
console.log(val)
await api
.uploadGalaryImage(fileId, valImageFile)
.then((res) => {
const imageView = api.sdk.storage.getFileView(api.galaryImagesBucket, fileId)
console.log(val)
// delete val.photos
// if (val.photos != undefined) {
// imageView.href
// val!.photos = imageView.href
// }
// val?.photos = imageView.href
val?.photos.push(imageView.href)
})
.catch((err) => {
hasErrors = true
form.setFieldError(`data.${i}.posterFile`, err.message)
})
.finally(() => {
setPostersUploadingId(-1)
delete val.posterPhotos
})
})
FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.
Please share the code for updateGalaryScroll()
Recommended threads
- Update User Error
```ts const { users, databases } = await createAdminClient(); const session = await getLoggedInUser(); const user = await users.get(session.$id); if (!use...
- apple exchange code to token
hello guys, im new here 🙂 I have created a project and enabled apple oauth, filled all data (client id, key id, p8 file itself etc). I generate oauth code form...
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...