This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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