How to get AEM note properties from clientlibs-js? | Community
Skip to main content
bhoang
New Participant
January 24, 2019
Solved

How to get AEM note properties from clientlibs-js?

  • January 24, 2019
  • 2 replies
  • 2875 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by edubey

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).

2 replies

bhoang
bhoangAuthor
New Participant
January 28, 2019

Thanks you for your help,

Could you help me an example?

edubey
edubeyAccepted solution
New Participant
January 24, 2019

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).