This is the HTML structure...
<head>
...
<script>
ENV = {...,
current_user: {
id: "314",
display_name: "My name"
}
}
<script/>
...
<head/>
I'm trying to read "display_name" to use in another part of the application.
If I press F12 and run the below in the console it works returning the name:
console.log(ENV.current_user.display_name)
but below doesn't work inside same page of the above:
<script>
const x = ENV.current_user.display_name;
document.getElementById("std").innerHTML = x;
</script>
<h3 id="std"></h3>
How can I print "My name" inside this h3?