Unable to receive an offer when using Node.js SDK
Hello, everyone! Would somebody mind helping me with the SDK implementation?
I'm trying to integrate Adobe Target from the server but I'm not receiving the experiment when using the Node.js package on a Next.js app...
import TargetClient from '@adobe/target-nodejs-sdk';
const CONFIG = {
client: '*****',
organizationId: '*****@AdobeOrg',
events: {
clientReady: () => console.log('Adobe Target client is ready.'),
},
};
const targetClient = TargetClient.create(CONFIG);
export async function getTargetAttributes(mboxNames, cookies) {
const targetCookie = cookies[TargetClient.TargetCookieName];
try {
const response = await targetClient.getAttributes(mboxNames, { targetCookie });
return {
attributes: response.asObject(mboxNames[0]),
targetCookie: response.getResponse().targetCookie,
};
} catch (error) {
console.error('Error fetching Target attributes:', error);
return { attributes: {}, targetCookie: null };
}
}export const getServerSideProps: GetServerSideProps = async (context) => {
const allCookies = context.req.cookies;
const mboxNames = ['server-side-mbox'];
const { attributes, targetCookie } = await getTargetAttributes(mboxNames, allCookies);
console.log({ attributes, targetCookie });
return {
props: {
offersResponse: attributes ?? null,
},
};
};This is the full response:
{
visitorState: { '*****@AdobeOrg': { sdid: [Object] } },
request: {
requestId: 'fe5150c61f1742b69c824d67aea7f16c',
id: {
tntId: 'b1798ab729674bf69e23704f390d17a2.37_0',
thirdPartyId: undefined,
marketingCloudVisitorId: undefined,
customerIds: undefined
},
context: {
channel: 'web',
mobilePlatform: undefined,
application: undefined,
screen: undefined,
window: undefined,
browser: undefined,
address: undefined,
geo: undefined,
timeOffsetInMinutes: undefined,
userAgent: undefined,
clientHints: undefined,
beacon: undefined
},
experienceCloud: { audienceManager: undefined, analytics: [Object] },
execute: { pageLoad: undefined, mboxes: [Array] }
},
targetCookie: {
name: 'mbox',
value: 'session#34323609087608251634124214122594614259-NSKwEX#1759165204|PC#b1798ab729674bf69e23704f390d17a2.37_0#1822408144',
maxAge: 63244801
},
targetLocationHintCookie: { name: 'mboxEdgeCluster', value: '37', maxAge: 1860 },
meta: {
decisioningMethod: 'server-side',
remoteMboxes: [],
remoteViews: []
},
response: {
status: 200,
requestId: 'fe5150c61f1742b69c824d67aea7f16c',
id: {
tntId: 'b1798ab729674bf69e23704f390d17a2.37_0',
thirdPartyId: undefined,
marketingCloudVisitorId: undefined,
customerIds: undefined
},
client: '*****',
edgeHost: 'mboxedge37.tt.omtrdc.net',
execute: {
pageLoad: undefined,
mboxes: [
{
'$type': undefined,
index: 1,
name: 'server-side-mbox',
options: undefined,
metrics: undefined,
analytics: undefined,
trace: undefined
}
]
},
prefetch: undefined,
notifications: undefined,
telemetryServerToken: 'cJWuCgDiaU1IgPqDGhBbFCzJjYT5KcJQavNWbBgQ1eQ='
}
}When hitting the API directly, it works. Any idea? Many thanks!

