Expand my Community achievements bar.

Join us for an upcoming in-person Adobe Target Skill Builders event ~~> We're hosting these live learning opportunities to equip you with the knowledge and skills to leverage Target successfully. Learn more to see if we'll be coming to a city near you!
SOLVED

Use applyOffers on JSON Offer

Avatar

Level 2

Is it possible to apply a JSON Offer in the `response.prefetch.mboxes` path in `applyOffers`? I am able to see the offer using `getOffers` but the offer is not applying.

 

I am also getting an error message of:

 

 

 

message: "Expected an array of promises"

 

 

 

 

I am doing exactly as the example shows in the getOffers documentation. Here is my code:

 

 

 

  adobe.target.getOffers({
    request: {
      prefetch: {
        mboxes: [
          {
            "index": 0,
            "name": "testMbox"
          },
        ]
      }
    }
  }).then(response => {
    const mboxes = response.prefetch.mboxes;
      mboxes.forEach(mbox => {
        adobe.target.applyOffers({
          selector: '#headerWrapper',
          response: {
            prefetch: {
              mboxes: [mbox]
            }
          }
        });
      });
    });

 

 

 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

API
1 Accepted Solution

Avatar

Correct answer by
Level 2

Hi @bmendez,

As per this Experience league article on create JSON offer,

JSON offers are not applied automatically as opposed to other offers (such as HTML offers) because JSON offers are non-visual offers. Developers must write code to explicitly get the offer using getOffer().

View solution in original post

1 Reply

Avatar

Correct answer by
Level 2

Hi @bmendez,

As per this Experience league article on create JSON offer,

JSON offers are not applied automatically as opposed to other offers (such as HTML offers) because JSON offers are non-visual offers. Developers must write code to explicitly get the offer using getOffer().