Expand my Community achievements bar.

SOLVED

How to get AEM note properties from clientlibs-js?

Avatar

Level 4

Hi friends,

I created a note settings/hostconfiguration/jcr:content to configuration (subscription key, service host) for my site. So, I create a clientlib clientlib-config (/etc/designs/abc/clientlib-config) to config the sub scription key and service host.

Example:

settings/hostconfiguration/jcr:content

apiMSubcriptionKey String value="abcxyz123"

serviceHost String value="http://0.0.123.5:8080/service/api/"

config.js code in the clientlib-config

var apiMSubcriptionKey = "abcxyz123";

var url_host = window.location.protocol + "//" + window.location.host;

var url_service = {

    'URL': 'http://0.0.123.5:8080/service/api/',

    'URL_UPLOAD_IMAGE': '/bin/uploadavatar',

    'SUB' : {

        'Ocp-Apim-Subscription-Key': apiMSubcriptionKey,

        'Authorization': !!localStorage.getItem("__USER_TOKEN")? "Bearer " + localStorage.getItem("__USER_TOKEN"): ""

    }

};

In the config.js, I want to get the content value of the apiMSubcriptionKey and serviceHost from settings/hostconfiguration/jcr:content to replace the hard code in config.js.

How to do that?

Thanks & Best regards,

BienHV

1 Accepted Solution

Avatar

Correct answer by
Level 10

As long as technical challenge is concerned, you can make a call to this url  settings/hostconfiguration/jcr:content in json format and get the node data in response.

On other note, if you are planning to do this in publish/prod you may have to double check. If these are secret keys, you may want to perform these operations in backend (java).

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

As long as technical challenge is concerned, you can make a call to this url  settings/hostconfiguration/jcr:content in json format and get the node data in response.

On other note, if you are planning to do this in publish/prod you may have to double check. If these are secret keys, you may want to perform these operations in backend (java).

Avatar

Level 4

Thanks you for your help,

Could you help me an example?