Skip to content

Instantly share code, notes, and snippets.

@neilkillen
Last active August 18, 2022 16:03
Embed
What would you like to do?
/**
* Gets Guest Information using Sitecore Personalize Flow Execution
* @param browserId
* @returns json object
*/
async function getGuestInformation(browserId:any)
{
let webExperienceId = 'get_guest_information'
var result = null
try
{
let flowExecutionModel = {channel: channel,
language: language,
currencyCode: currency,
pointOfSale: pos,
clientKey: clientKey,
friendlyId: webExperienceId,
browserId: browserId}
let request = `https://${cdpEndpoint}/v2/callFlows`
const response = await fetch(request, { method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(flowExecutionModel)
})
if(response.ok)
{
result = await response.json();
}
}
catch(err:any)
{
console.log(`getGuestInformation Error retrieving Guest Information from ${webExperienceId}: ${err}`)
}
finally {
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment