Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Not able to consum js use API in sightly

Avatar

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

Avatar

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