0

I am trying to update a user object using the JS-SDK but I am getting Duplicate key for schema error. What is the correct way to update a user object using StackMob JS-SDK? Below is my code

var Usr = StackMob.Model.extend({schemaName: 'user'});
var rid = window.localStorage.getItem("devicetoken");
var usr = new Usr({ username: rid });
usr.set({sendnotification: true });
usr.save({
  success: function(model, result, options) { console.log('saved'); },
  error: function(model, result, options) {console.debug('failed:'+result.error);}
});
Uyghur Lives Matter
  • 18,820
  • 42
  • 108
  • 144
jai
  • 25
  • 5

1 Answers1

0

Figured out the answer, you need to use the User object directly. There is no need to extend the model

    var user = new StackMob.User({ username: rid, sendnotification: true});
    user.save({
        success: function(model, result, options) { console.log('saved'); },
        error: function(model, result, options) {console.debug('failed:'+result.error);}
    });
jai
  • 25
  • 5