설명서Target 개발자 안내서

속성 가져오기(Node.js)

마지막 업데이트: 2024년 7월 20일
  • 주제:
  • APIs/SDKs

작성 대상:

  • 개발자

설명

getAttributes()은(는) Target에서 실험과 개인화된 경험을 가져오고 특성 값을 추출하는 데 사용됩니다.

방법

getAttributes

TargetClient.getAttributes(mboxNames: Array, options: Object): Promise

매개 변수

이름유형필수기본값
mboxNames배열예없음
options개체아니오없음

약속

TargetClient.getAttributes()이(가) 반환한 Promise은(는) 다음 메서드를 사용하여 개체를 확인합니다.

방법반환 유형설명
getValue(mboxName, key)Any지정된 mbox 이름 및 속성 키에 대한 값을 반환합니다.
asObject(mboxName)개체키 값 쌍이 있는 단순 json 개체 반환
getResponse()getOffers 응답getOffers이(가) 정상적으로 반환한 응답 개체를 반환합니다.

예

Node.js

const TargetClient = require("@adobe/target-nodejs-sdk");
const CONFIG = {
  client: "acmeclient",
  organizationId: "1234567890@AdobeOrg"
};

const targetClient = TargetClient.create(CONFIG);
const offerAttributes = await targetClient.getAttributes(["demo-engineering-flags"]);


//returns just the value of searchProviderId from the mbox offer
const searchProviderId = offerAttributes.getValue("demo-engineering-flags", "searchProviderId");

//returns a simple JSON object representing the mbox offer
const engineeringFlags = offerAttributes.asObject("demo-engineering-flags");

//  the value of engineeringFlags looks like this
//  {
//      "cdnHostname": "cdn.cloud.corp.net",
//      "searchProviderId": 143,
//      "hasLegacyAccess": false
//  }

const assetUrl = `http://${engineeringFlags.cdnHostname}/path/to/asset`;
recommendation-more-help
6906415f-169c-422b-89d3-7118e147c4e3