Passing .link to a Button

Hello,

I have a working code, but only working in the console. I am trying to figure out how to apply a link (that generates in console as expected) to a second button. The issue is that when I click button2 nothing happens. Almost like the link didn’t apply. Here is what I have:

$w . onReady ( function () {

let url ;
$w ( “#button1” ). onClick ( async ()=>{ //button1 is clicked and it generates a PDF Link from input fields
const titlefield = $w ( “#input1” ). value ;
const datefield = $w ( “#input6” ). value ;
const fromfield = $w ( “#input3” ). value ;
const quickfield = $w ( “#input7” ). value ;
const ccfield = $w ( “#input4” ). value ;
const impactfield = $w ( “#input5” ). value ;
const mainfield = $w ( “#richTextBox2” ). value ;
const data = { titlefield , datefield , fromfield , quickfield , ccfield , impactfield , mainfield };
const url = await generatePDFfromData ( data ); //apply data to ‘url’
console . log ( url ) //console outputs correct link (works till this point)
})
$w ( “#button2” ). link = url ; //apply ‘url’ to button2… but button2 doesn’t respond
$w ( “#button2” ). target = “_blank” ;
})