Skip to content

Instantly share code, notes, and snippets.

@neilkillen
Last active Aug 18, 2022
Embed
What would you like to do?
/**
* This function is used to Get the Browser Ref from Sitecore Personalize
* @returns browserId
*/
async function getBrowserRef()
{
let browserId = "";
var result = null
try
{
let request = `https://${cdpEndpoint}xx/v1.2/browser/create.json?client_key=${clientKey}&message={}`
const response = await fetch(request, {method: 'GET'});
if (response.ok)
{
result = await response.json();
if(isGuid(result.ref)){
browserId = result.ref
}
}
}
catch(err:any)
{
console.log(`getBrowserRef Error retrieving Browser from Sitecore Personalize: ${err}`)
}
finally {
return browserId;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment