Search code examples
monaca

MC.User.login -> MC is unknown


Probably a simple answer but where comes the MCobject from? How can I set it. I Keep getting an error that states that MC is unknown in the following code:

MC.User.login(email, password)
.done(function()
{
  console.log('Login is success!');
  getMemoList();
  $.mobile.change('#ListPage');
})
.fail(function(err)
{
  console.log(err.message);
  alert('Login failed!');
});

Solution

  • I think you are using the wrong API structure. For javascript, use these docs: https://docs.monaca.io/en/reference/monaca_api/cloud/

    Specifically, for login:

        monaca.cloud.User.login("[email protected]", "password")
    .done(function(result){
       console.log("Hello again, " + result.user._username);
    })
    .fail(function(err)
    {
       console.log("Err#" + err.code +": " + err.message);
    });
    

    You are getting an error, because it is not MC but monaca.cloud.....