I am building a Confluence Cloud App with Connect. I want to get the Page ID (Content ID) of the page, where the Macro is put on. I’m working in the View-Folder of my Connect-App in a .hbs-file.
I can get the ID by using getContext(), but I can’t put it in a variable for later usage, because of the scope.
I can work in the unnamed function in the .then() part now, but maybe it’s a stupid question, but is there a possibility to get the result (the pageID) out of the scope of that unnamed function?
I see… I need to read about async JavaScript…
Your earlier code already made the pageID available outside of the callback. The problem however is that you don’t know when the callback returns (when the console.log runs, it has not yet returned).
Reading up on callbacks and promises should help.