Currently I have the following code:
let getThemeId = getMainThemeId();
getThemeId.then(id => {
themeId = id;
csi.evalScript("exportAIHtml()", function(result){
alert(result);
});//main()
});
getTheme is a method that returns a value and then I'm able to run .then. First part works correctly. csi.evalScript is a method prebuilt into a module I'm using. It returns a callback so I can use the result. For code clarity I would like to use the result in another then.
I've attempted this:
let getThemeId = getMainThemeId();
getThemeId
.then(id => {
themeId = id;
return csi.evalScript("exportAIHtml()", function(result){
return (result);
})
.then(result => alert(result));
The alert there is appearing as undefined so obviously it's not waiting for it to finish executing. Would this have to be wrapped in a new promise to get it to work as expected? Shouldn't it just chain it and continue the then?