属性の取得(Node.js)

説明

getAttributes()は、Targetから実験とパーソナライズされたエクスペリエンスを取得し、属性値を抽出するために使用されます。

メソッド

getAttributes

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

パラメーター

名前
タイプ
必須
デフォルト
mboxNames
配列
○
None
options
オブジェクト
×
None

約束

TargetClient.getAttributes()が返したPromiseは、次のメソッドを使用してオブジェクトを解決します。

メソッド
戻り値の型
説明
getValue (mboxName, key)
任意
指定したmbox名と属性キーの値を返します
asObject (mboxName)
オブジェクト
キーと値のペアを持つシンプルなjson オブジェクトを返します
getResponse ()
getOffers Response
通常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
target-dev-help-dev