How to handle cloudboost errors in Ionic2?

63 Views Asked by At

The error I get when the user fails to log in is "Error: Request failed with status code 401". This error is logged here:

static login(username : string, password : string){
    return new Promise(resolve =>{
        let user = new CB.CloudUser();
        user.set('username', username);
        user.set('password', password);
        user.logIn({
          success: function(user) {
            console.log("user");
            resolve();
          },
          error: function(error) {
            console.log(error);
            resolve(error);
          }
        });
    });
}

But what I need is the error that actually says what went wrong e.g. "invalid username" or "User is not authenticated".

How do I get these?

1

There are 1 best solutions below

0
On
Error: Request failed with status code 401

This error generally means that the login request you made to the server was not authenticated/ you were not authorized to make the login request. This can mean that the CB instance is not properly initialized. Please check the appId and the master/client key you are using to initialize the CB instance.