Recent searches


No recent searches

Guide 코드 편집에서 외부 API 쓰기



Posted May 14, 2024

Guide 관리센터에서 코드 편집으로 script.js 에 외부 API 를 쓰고 싶습니다.  예를 들어서 

 

document.write('<script src="https://static.zdassets.com/zendesk_app_framework_sdk/2.0/zaf_sdk.min.js"></script>');
document.addEventListener('DOMContentLoaded', function() {

 var site = "https://AAA.zendesk.com"
 const client = ZAFClient.init();
 //zendesk api 읽기
    function zendesk_api(url)  {
        const options = {
             url: url,
             type: "GET",
             autoRetry: false,
        };
        
        return options
    }
    options = zendesk_api(site + "/api/v2/users/search?role=admin")
            client.request(options).then((response) => {
                console.log(response['users'])
            });

 

이런식으로 쓰고 싶은데 에러가 나네요. 방법이 있을까요?

 


0

1

1 comment

End-User 나 로그인한 User의 정보를 가져오려는 목적이라면

ZAFClient 로도 충족 가능합니다.

var client = ZAFClient.init();

   client.get('currentUser').then(function(data) {
       var userCheck = data.currentUser;
       var userEmail = userCheck.email;
       if (userCheck.role === 'admin') {
           console.log('User is an admin');

       }

https://developer.zendesk.com/api-reference/apps/apps-chat-api/all_locations/#currentuser-object

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post