Back

Update Document method issue

  • 0
  • Databases
  • Web
  • Cloud
Sanchit Bajaj
1 May, 2024, 16:19

does anyone know what is this error mean? I am uploading a file into bucket and manually creating public URL for the image and storing it into database. I am getting this error on updating the document

TypeScript
const result = await db.updateDocument(dbName, usersCollection, userId, {
    bannerURL: image,
});

I am getting this image from other method and tested that I am getting the data in image variable

TL;DR
Developers are experiencing an issue with the updateDocument method. They are trying to upload an image to a bucket, create a public URL, and store it in a database. They are getting an error when updating the document. The code appears to be in order, but they are not able to copy as curl and are unsure how to proceed.
Binyamin
1 May, 2024, 16:31

Can you share the payload was sent by the browser?

Binyamin
1 May, 2024, 16:31

Like so?

Sanchit Bajaj
1 May, 2024, 16:33
Binyamin
1 May, 2024, 16:34

This is weird can you past the whole request CURL?

Binyamin
1 May, 2024, 16:36

Everything seems in order

Binyamin
1 May, 2024, 16:36
  • Here you're getting back good results?
  • Is your code wrapped in try/catch?
Sanchit Bajaj
1 May, 2024, 16:52

no option to copy as curl

Sanchit Bajaj
1 May, 2024, 16:54

Here is the entire function:

TypeScript
const updateImageURL = async (userId: string, image: string, isBanner: boolean) => {
  try {
    console.log(image);

    if (isBanner) {
      const result01 = await db.updateDocument(palettegramDB, usersCollection, userId, {
        bannerURL: image,
      });
      if (!result01) {
        throw new Error("Error in updating user image");
      }
      return result01;
    } else {
      const result02 = await db.updateDocument(palettegramDB, usersCollection, userId, {
        avatarURL: image,
      });
      if (!result02) {
        throw new Error("Error in updating user image");
      }
      return result02;
    }
  } catch (error: any) {
    console.log(error);
  }
  return null;
};
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more