I have a problem. I am trying to get a single row from my database. I have done that with an API like this:
function getUserData() {
let returnData = "";
MyApplication.API.queryDatabase("SELECT * FROM users WHERE Id = ?", 1).done(function(data) {
returnData = data;
}).fail(function(reason) {
console.log(reason);
});
return returnData;
}
And I use it like this:
let userData = getUserData();
Now this results me in the following: 0: Lastname: "Justme" Email: "just.a.test@email.com" Gender: "Male" Id: 1 Origin: "Nederland" Phonenumber: "0612345678" Firstname: "Alexander"
Now I am trying to store a single value in a variable, but when I print it, it prints:
undefined
While trying this code:
let userFirstname = userData.Firstname;
console.log(userFirstname);
How can I fix this?