Unfortunately, this forum tends to “eat” macros and HTML elements if you don’t select and then mark them using the “Preformatted text” button (the “</>” button) on the editor window. Since we can’t see what macro is throwing the error, it’s a bit more difficult to figure out where the problem is.
That said, it might be due to the “isAsync : true,” code in that old sample code, since I don’t see that in the Macro API documentation. It’s possible (if not likely) that things have changed in SugarCube in the intervening 2 1/2 years since that code was written.
If your code is any different from the code on the page you linked to, it would be best to just post that code here within a “preformatted text” block, so we can see if there are any errors in it.
Thanks.
P.S. The code you’re talking about is not Java code, it’s JavaScript. While they’re somewhat related, the old joke is that they’re like the words “car” and “carpet”, in that they may use the same word, but they’re quite different things.