获取属性(Node.js)
描述
getAttributes()
用于从Target获取试验性和个性化体验并提取属性值。
方法
getAttributes
TargetClient.getAttributes(mboxNames: Array, options: Object): Promise
参数
名称
类型
必需
默认
mboxNames
数组
是
无
options
对象
否
无
Promise
TargetClient.getAttributes()
返回的Promise
使用以下方法解析对象:
方法
返回类型
描述
getValue(mboxName, key)
“任一”
返回指定mbox名称和属性键的值
asObject(mboxName)
对象
返回具有键值对的简单json对象
示例
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