Can't load avatar URL

Can I ask basic JS here?

If I do

        const avatarUrl = "avatarUrl"
        const button = document.getElementById('button');
        // Get avatar GLB URL
        if (json.eventName === 'v1.avatar.exported') {
            console.log(`Avatar URL: ${}`);
            document.getElementById('avatarUrl').innerHTML = `Avatar URL: ${}`;
            document.getElementById('frame').hidden = true;
            document.getElementById('base').hidden = false;
            avatarUrl =;
        button.addEventListener('click', function () {
            avatarurl.textContent = avatarUrl

After event when I click the button the result is not avatar URL but ‘avatarUrl’. How to get that avatar URL?

I need form? Didn’t try that.

For now it’s the solution. Not sure the better one.