Skip to content

Instantly share code, notes, and snippets.

@neilkillen
Last active August 18, 2022 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neilkillen/2699cb5c522dcfd0c4c6f35659bcdf16 to your computer and use it in GitHub Desktop.
Save neilkillen/2699cb5c522dcfd0c4c6f35659bcdf16 to your computer and use it in GitHub Desktop.
/**
* 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