Edit in GitHubLog an issue

Get Attributes

Description#

getAttributes() is used to fetch experimentation and personalized experiences from Target and extract attribute values.

Method#

Copied to your clipboard
TargetClient.getAttributes(mboxNames: Array, options: Object): Promise

Parameters#

NameTypeRequiredDefault
mboxNamesArrayYesNone
optionsObjectNoNone

Promise#

The Promise returned by TargetClient.getAttributes() resolves an object with the following methods:

MethodReturn TypeDescription
getValue(mboxName, key)AnyReturns the value for a specified mbox name and attribute key
asObject(mboxName)ObjectReturns a simple json object with key value pairs
getResponse()getOffers ResponseReturns the response object normally returned by getOffers

Example#

Copied to your clipboard
1const TargetClient = require("@adobe/target-nodejs-sdk");
2const CONFIG = {
3 client: "acmeclient",
4 organizationId: "1234567890@AdobeOrg"
5};
6
7const targetClient = TargetClient.create(CONFIG);
8const offerAttributes = await targetClient.getAttributes(["demo-engineering-flags"]);
9
10
11//returns just the value of searchProviderId from the mbox offer
12const searchProviderId = offerAttributes.getValue("demo-engineering-flags", "searchProviderId");
13
14//returns a simple JSON object representing the mbox offer
15const engineeringFlags = offerAttributes.asObject("demo-engineering-flags");
16
17// the value of engineeringFlags looks like this
18// {
19// "cdnHostname": "cdn.cloud.corp.net",
20// "searchProviderId": 143,
21// "hasLegacyAccess": false
22// }
23
24const assetUrl = `http://${engineeringFlags.cdnHostname}/path/to/asset`;
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell my personal information
  • AdChoices
Copyright © 2022 Adobe. All rights reserved.