How to use Promise in javaScript activity | Community
Skip to main content
Level 2
April 2, 2021
Question

How to use Promise in javaScript activity

  • April 2, 2021
  • 3 replies
  • 2203 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

Milan_Vucetic
Level 9
April 5, 2021

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
Community Manager
Community Manager
April 13, 2021

Hi @jamesalio,

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

Thanks!

 

Sukrity Wadhwa
JamesAlioAuthor
Level 2
April 13, 2021

Hello @sukrity_wadhwa 

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

marcinkacz
Level 3
April 14, 2021

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