Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Not able to consum js use API in sightly

lovepreetk75597
Level 3
Level 3

Hi,

I ma trying to consume js use API in sightly but it is not working. Following are my js and htl files:-

abc.js:-

'use strict';

use(function () {

    alert("inside");

    var message = "Hello World";

    return {

       

        hello: message

    };

});

abc.html:-

<div data-sly-use.logic="abc.js">

    ${logic.hello}

</div>

Ideally it should print "Hello world". Also that alert is not coming.

Am i missing out something?

Thanks in advance.

Regards,

Lovepreet

2 Replies
berliant
Employee
Employee

Within your sample, you need to make sure that you placed your js next to abc.html.

Here is an example for We.Retail:

1748806_pastedImage_0.png

1748873_pastedImage_1.png

The code sample is from HTL and the JavaScript Use-API