Doubts on Updating Object inside a class

Hi, every time I try to update an entry it creates a new obj in moralis. Any clues? Is there something similar to setUserData also for for classes? What am I missing? Thanks

Code explanation:
After submitting a form I need to save a new object if it doesn’t exist, or to update it if it exists.

 const onSubmit = ({ instagram_profile, youtube_url, about }) => {
    setSaveIsLoading(true);
  
    save({
      instagram_profile,
      youtube_url,
      about,
      profile_photo: photo,
      cover_photo: cover,
      user_id: user.id,
    })
      .then(() => {
        notifySuccess();
        setSaveIsLoading(false);
        setCover(null);
        setPhoto(null);
      })
      .catch(() =>
        notifyError('Error saving you profile page data. Try again.')
      );
 
  };

I tried also with plain JavaScript like this:

 const Guides = Moralis.Object.extend('Guides');
 const guide = new Guides();
 guide.set({
        instagram_profile,
        youtube_url,
        about,
        profile_photo: photo,
        cover_photo: cover,
        first_name: user.attributes.first_name,
        last_name: user.attributes.last_name,
        user_id: user.id,
      });
guide.save();

Here you are my Master! :smiley: @ivan

1 Like

i think the only error that i see is at the end, which you should be using await

should be await guide.save()

You can check this video to get a better idea about saving items on moralis.
https://www.youtube.com/watch?v=jgClkiMbWl0&list=PLFPZ8ai7J-iR6DMqBfZwJGc0vaNZPbJDv&index=5

Carlos Z