Trying to read value from back4app object and set it to a variable but getting error: Cannot set property 'loginName' of undefined

206 Views Asked by At

This is my codde, writing it to the console works fine, error occurs when assign the value to a variable.

const User = Parse.Object.extend("User");
            const query = new Parse.Query(User);
            query.equalTo("username", this.userData.getUsername);
            query.first().then(function(myuser){
            if(myuser){
               this.loginName = myuser.get('username');
               console.log(this.loginName)
            } else {
               console.log("Nothing found, please try again");
            }
        }).catch(function(error){
            console.log("Error: " + error.code + " - " + error.message);       
        });
0

There are 0 best solutions below