Expand my Community achievements bar.

How to load data from Granite.author.page.info from clientlib

Avatar

Level 5

On my author, I have a js clientlib (loading up in the cq.authoring.editor.hook category) where I'm trying to read data from Granite.author.page.info:

(function(window, document, Granite, $) { "use strict"; info = Granite.author.page.info; ...

Unfortunately, this data seems to load asynchronously, so I get an undefined error in my javascript. I know I can request the data from the pageinfo.json endpoint, but I'm wondering if there's built in functionality to pull that data, or wait for a promise.

I also tried Granite.author.page.fetchPageInfo() and then using the done() method, however, I get the same undefined error.

1 Reply

Avatar

Level 5

Strike that... I was tryting to assign the fetchPageInfo() method to my info variable, but the correct implementation is this:

 

Granite.author.page.fetchPageInfo().done(function (info) { ...