Hyperlink Text Box in Repeater/Wix code SDK error

I’m trying to create clickable text within a repeater that links to a URL. Because this text is also connected to text in a database, I have to use code to hyperlink it (rich text and transparent buttons aren’t options with my website design), but my below code doesn’t seem to work. In preview mode, the text appears to be clickable, but doesn’t open to a link. This error message appears when I attempt to click it: Wix code SDK error: The url parameter that is passed to the to method cannot be set to the value . It must be of type string.

What am I doing wrong?

import wixLocation from ‘wix-location’ ;
$w.onReady( function () {

$w( '#repeater5' ).onItemReady((selector, itemData, index) => { 

    $w( '#Hed1' ).onClick(() => { 

        wixLocation.to(itemData.link);

Hello Jessica.

What do you get in conssole, when doind this…

console.log(itemData.link)
console.log(typeof itemData.link)

What are the results?
The wixLocation.to"wixLocation.to-command" expects a STRING, like…

wixLocation.to("https://www.google.com");

So perhaps this would work…

 let myLink = (itemData.link).toString()
 wixLocation.to(myLink);

Thanks for this! I realize I forgot to mention I’m trying to create a hyperlink to links in my database–since this is a repeater and the URL differs depending on the text that appears–so, I haven’t input a string because there’s no one string.

When you have realized something —> it’s a progress :grin:
Then you are surely now able to solve it. You recognized the bug, now try to debug your code. Always use —> CONSOLE, it will alwasys help you debugging your own code.

When you see what you get as RESULT, you will be able to understand.
And when you will be able to understand—> you will be able to debug :wink:

@russian-dima Thank you, but actually, this is my first time coding and I’m not quite sure where to go from here… I’m looking at the codes, but not sure how to add to the above to pull URL from database collection.

@jtoscano
Take a look at this example, perhaps it may help you a little bit

https://russian-dima.wixsite.com/meinewebsite/repeater-problem

$w.onReady(function () {
    $w("#dataset8").onReady( () => {
        $w("#repeater1").onItemReady( ($item, itemData, index) => {
            $item("#myRepeatedText").text = itemData.textField;
            $item("#BTNedit").onClick((event) => {
            console.log(itemData)
            console.log("Title / " + itemData.title)
            console.log("Message / " + itemData.comments)
            });
        });
    });
});

This example shows you different comments which are stored in a DATABASE (“Comments”).

This example has a direct connection to this example here…
https://russian-dima.wixsite.com/meinewebsite/comments

  1. Take a look at the given REPEATER.
  2. Press the “EDIT” button and take a look into CONSOLE.
  3. What do you see?:grin:

@russian-dima For the most part, this has been helpful, thank you!

@jtoscano
:wink: Do not forget to like it, if you really liked it sweety.