Clicking on a button, wait 3 seconds and redirect to a site on my page

In editorx when you connect a button to a database and at the same time to a link it doesn't work.
I need a code that when clicking on a button, wait 3 seconds and redirect to a site on my page. while I leave the button connected to the database. I think it could work. Could you help me?
import wixLocation from 'wix-location'
$w('#button').onClick(()=>{
setTimeout(()=>{wixLocation.to('https://www.google.com')
}, 3000)
})

Set timeout = Add delay
3000 = 3000 milionseconds (3 secs)

You have to do your own modification to make it work on your case. Copy and paste won’t work.

Thank you very much for your answer! it works fine, but I need it to be from an internal page since otherwise some things work badly later. in the code something like : /mysite/pag1