属性を取得(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 応答 ​
通常 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