Skip to main content

Using fetchPath() I can retrieve the current conversation URL, but the function returns a Promise Object.

How do I get the “PromiseResult” value from the object, ie. how do I get the path into a string?

Front.contextUpdates.subscribe(context => {
let path = context.fetchPath();
});

 

It’s using the Javascript async/await model, so you’ll just need to await the call;

 


let path = await context.fetchPath()


 


Thanks a lot for the tip. In case someone else is looking for a similar solution. Here is the complete snippet that worked for me.

  • Make the script a module
  • Add the async scope to context
<script type="module">
Front.contextUpdates.subscribe(async (context) => {
let path = await context.fetchPath();
console.log('Path:', path);
});
</script>

 


Reply