DocumentazioneGuida per gli sviluppatori di Target

Ottieni attributi (Node.js)

Ultimo aggiornamento: 20 luglio 2024
  • Argomenti:
  • APIs/SDKs

Creato per:

  • Sviluppatore

Descrizione

getAttributes() viene utilizzato per recuperare esperienze di sperimentazione e personalizzate da Target ed estrarre i valori degli attributi.

Metodo

getAttributes

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

Parametri

NomeTipoObbligatorioPredefinito
mboxNamesArraySìNone (Nessuno)
optionsOggettoNoNone (Nessuno)

Promessa

Promise restituito da TargetClient.getAttributes() risolve un oggetto con i seguenti metodi:

MetodoTipo restituitoDescrizione
getValue(mboxName, key)AnyRestituisce il valore per il nome mbox e la chiave attributo specificati
asObject(mboxName)OggettoRestituisce un oggetto json semplice con coppie chiave-valore
getResponse()Risposta getOffersRestituisce l'oggetto di risposta normalmente restituito da getOffers

Esempio

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