Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Passing user profile information

ANSWERED

I am needing to display user information on my app screen and having some issues. Example - I want to display the users age.

 

In my app/index.js file, I have:

import { user } from "user-profile";

console.log(user.age);  - DISPLAYS IN LOG

let userAge = JSON.stringify(user.age);

console.log(userAge);  - DISPLAYS IN LOG

 

In my resources/index.gui file I have:

<text x="10%" y="70%" id="userAge"></text>

 

It displays nothing on the gui. I am sure I am missing something simple here.

Any help is appreciated.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Thanks for your assistance. I was actually able to resolve it with the below:

 

let userAge = ("Age: " + user.age);
var age = document.getElementById("age");
age.text = userAge;

View best answer in original post

Best Answer
0 Votes
2 REPLIES 2

A visual element won't be updated just because it's got the same id as a variable name. You need code to make it happen.

 

This will be wrong (because off the top of my head); fixing it is left as an exercise to the developer:

let ageElement = document.getElementById("userAge");
ageElement.text = userAge;
Peter McLennan
Gondwana Software
Best Answer
0 Votes

Thanks for your assistance. I was actually able to resolve it with the below:

 

let userAge = ("Age: " + user.age);
var age = document.getElementById("age");
age.text = userAge;

Best Answer
0 Votes