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

How to use Promise in javaScript activity

JamesAlio
Level 2
Level 2

Hello,

i want to use the following code in a javascript activity but im getting an error : 

var myPromise = new Promise(function(myResolve, myReject) {
  setTimeout(function() { myResolve("I love You !!"); }, 3000);
});

myPromise.then(function(value) {
 logInfo('Helllo Promise : '+value);
});

 

this is the error that i get :  02/04/2021 16:02:11 js7 JST-310000  ligne 2 : Promise is not defined.

 

do you have any solution please ?

Thanks in advance.

5 Replies
Milan_Vucetic
Community Advisor
Community Advisor

Hi @JamesAlio

it is not there by deafult.

You may try create a new JS library and copy code from here for example.

Finally, load library in your JS node or connector via loadLibrary("your_schema:Your_new_file.js");

 

This is not tested. If code does not work for you try with different ones (look for min.js extension)

Regards,

Milan

Sukrity_Wadhwa
Employee
Employee

Hi @JamesAlio,

Was the given solution helpful to resolve your query or do you still need more help here? Do let us know.

Thanks!

 

JamesAlio
Level 2
Level 2

Hello @Sukrity_Wadhwa 

no i still have the same problem. the Promise object is undefined in  my Js Activity

Sukrity_Wadhwa
Employee
Employee
Thanks for the update. I will escalate your issue further.
marcinkacz
Level 4
Level 4

Hi James,

I guess Promise doesn't work in Adobe Campaign. ACC Javascript implementation is Spider Monkey, so it is probably ECMAScript 5 (2009) standard. Promises were introduced with ECMA 6 (ECMAScript 2015).

Regards, Marcin