@madsteer This is the important part…
EXAMPLE:
.then((results) => {console.log(results)
let items = results.items
if(items.length > 0) {
let myURL = "https://www.google.de/"
wixLocation.to(myURL);
}
else {...}
});
IN YOUR CASE:
.then((results) => {console.log(results)
let items = results.items
if(items.length > 0) {
let myURL = results.items[0].url; console.log(myURL)
wixLocation.to(myURL);
}
else {...}
});
This is the wrong way…(but you also could do it like this, if you would use a return function) and await for the RESULT.
$w('#button1').onClick(()=>{console.log("Button-1 clicked!")
searchIndex(myValue)
wixLocation.to("https://wix.com");
});