Hi @Pravinrams1
At initial level, check that your Node SDK is properly initialized with the correct credentials. Incorrect or missing configuration for the Adobe services (like credentials, API keys, or tenant information) could result in invalid responses.
2) Make sure your Mbox is active and exists in Adobe Target.
3) When using the prefetch
method, ensure that you're not confusing it with execute
in your code. prefetch
is for retrieving offers in advance, but if the configuration or targeting is off, it could return undefined.
4) Caching issues - Sometimes cached offers or mismatches in timing (when the prefetch request is made vs when it's used) can cause issues. Please clear your cache.
5) Use logger optional object - in order to debug.
Here is the sample code again
import AdobeTargetClient from '@adobe/target-nodejs-sdk';
// Initialize client
const client = AdobeTargetClient.create({
client: '<YOUR_CLIENT_ID>',
organizationId: '<YOUR_ORG_ID>',
apiKey: '<YOUR_API_KEY>',
targetHostname: 'your-target-url',
logger: console
});
// Prefetch offers
client.getOffers({
sessionId: '<SESSION_ID>',
visitorId: '<VISITOR_ID>',
context: {
channel: 'web',
address: {
url: 'https://your-site.com',
},
browser: {
host: 'your-site.com',
userAgent: navigator.userAgent,
},
},
prefetch: {
mboxes: [
{
name: 'your-mbox-name',
index: 0
}
]
}
}).then((response) => {
console.log(response);
}).catch((error) => {
console.error('Error fetching offers:', error);
});