0

I know I am probably blind to something here, I am still new to learning all this. I am trying to modify a value in an object. The object is changing the way I want it by checking console.log(user), but for some reason, when the code gets to user.save(), it just returns this:

Error

async function healUser() {
  try {
    const customId = localStorage.getItem('Custom-User-ID');
    const query = new Parse.Query(Parse.User);
    query.equalTo("customId", customId);

    const user = await query.first();
    user.get("stats").health = user.get("stats").maxHealth;

    console.log(user)

    await user.save()
      .then((healedUser) => {
        healAlert();
      })
      .catch((error) => {
        console.error("Error: ", error);
      });

  } 
  catch (error) {
    console.error(error);
    // Handle any errors that occurred during healing process
  }
}

The code used to work for a good while, but suddenly I started getting this error. every other JS file that has the .save() returns a similar error.

I would have guessed I reached my limit on the Back4App requests, but I am just barely halfway through it.

I tried:

  • Comparing the object column names and values between the code and db
  • Changing the parse script header in my HTML to different versions
  • Clearing all browsing data and restarting Chrome/Opera/Firefox (tried live server in all 3)
  • Checking the back4app logs (Parse error: Cannot modify user 0dvbwwVi6h.)
  • Making a new back4app account just to test if it's an account/keys issue
  • Looking for a similar question/issue online
Robert Bradley
  • 548
  • 2
  • 21
Abrahim
  • 3
  • 5
  • Hi, I'm new to parse as well but just read in the documentation that you cannot change properties of a user if you're not using an authorized method see here: https://docs.parseplatform.org/js/guide/#security-for-user-objects – robin Jul 01 '23 at 04:14
  • To update a user, you must make sure you are using an authenticated user (the user itself) or using the master key. Since the master key on the front end is something insecure, you can use a cloud code function for this operation. They have an example, and you can use as base to your own solution: https://help.back4app.com/hc/en-us/articles/360045500871-How-to-update-a-user- – Charles Jul 31 '23 at 18:05

0 Answers0