JavaScript How to update user class in parse-platform using JavaScript SDK?

I am trying to update other user's information in Parse which is stored in User class. Initially I tried following code:

1.

var user = Parse.User;
var query = new Parse.Query(user);

query.equalTo("name", userName); //to find specific user

query.first({
     success: function(results) {
                //update that user's details
                results.set("name", newName);
                results.save();
      },
      error: function(error) {
                alert("Error: " + error.code + " " + error.message);
      }
});

I got following error:

{code: 206, error: "Parse::UserCannotBeAlteredWithoutSessionError"}

2. Then I used Parse.Cloud.useMasterKey(), as I figured out that we can not edit other user's details. But it didn't work either. And master key overrides all security, so it was not a good idea to use this code.

3. So I tried following code:

var user = Parse.User;
var query = new Parse.Query(user);

query.equalTo("objectId", userName);

query.first({
    success: function(results) {

                results.set("name", newName);

                results.save(null, { useMasterKey:true}).then(function(user) {console.log("updated!!!");}, function(error) {console.log(error); });

     },
     error: function(error) {
                alert("Error: " + error.code + " " + error.message);
     }
});

But I am getting '401 Unauthorized' error.

Does anyone know how to update other user's information in Parse? Any help would be greatly appreciated.

Answer:1

I'm using sw-toolbox, which is a library for service-worker provided by Google. I'd like to combine the cacheFirst strategy (see readme in link above) with a fetch from network after successfully ...

I'm using sw-toolbox, which is a library for service-worker provided by Google. I'd like to combine the cacheFirst strategy (see readme in link above) with a fetch from network after successfully ...

  1. force service worker update
  2. force reload service worker
  3. force unregister service worker
  4. force clear service worker cache
  5. force install service worker
  6. firefox force service worker update
  7. service worker force update cache
  8. service worker force update on reload
  9. service worker force activate

I have this Unicode character that I want to display using the new Unicode Point Escapes (i.e.e where someone uses '\u{Code Point Here}' However, I must be doing something wrong because doing ...

I have this Unicode character that I want to display using the new Unicode Point Escapes (i.e.e where someone uses '\u{Code Point Here}' However, I must be doing something wrong because doing ...

https://codepen.io/anon/pen/QNqgMo Why is the top line not animating? Could someone tell me what's wrong in the code? Thanks #hamburger-icon.active .line-1 { transform: translateY(25px) translateX(...

https://codepen.io/anon/pen/QNqgMo Why is the top line not animating? Could someone tell me what's wrong in the code? Thanks #hamburger-icon.active .line-1 { transform: translateY(25px) translateX(...

  1. isn't
  2. https://www.instagram.com/
  3. isnetworld
  4. instagram
  5. isn't she lovely
  6. isnt it romantic
  7. isna
  8. isn't it ironic
  9. isner
  10. isnull sql
  11. isn network
  12. isnac 2020
  13. isnt she lovely chords
  14. isns
  15. isnan
  16. isn't it
  17. isnull
  18. isn't it romantic cast
  19. isna excel
  20. disney plus

I'm trying to understand underscore's invoke() function, but I'm having trouble in a few areas. Here's the code from the annotated source: _.invoke = function(obj, method) { var args = slice....

I'm trying to understand underscore's invoke() function, but I'm having trouble in a few areas. Here's the code from the annotated source: _.invoke = function(obj, method) { var args = slice....