How to print only the hostname from a request url

Hey, I have a use case where i need to store the host URL as variable,
I used few scripts

  1. >> this gives output in array format like
    `[“app”, “xyz”, “com”]

  2. 0: “app”

  3. 1: “xyz”

  4. 2: “com”`

Can someone help me to print it like

@dannydainton need your help here

Thanks in advance

Hi @swasthik, you can do it using join() method :blush:

Please try the below snippet.

console.log("URL is : " +'.'));

Please let me know if this is your expectation :slightly_smiling_face:


yes, perfect Thanks @bpricilla :slight_smile:

1 Like

@swasthik Great to know!! Just sharing this link for you to know more about this join method :slightly_smiling_face:

You can also use this without using an additional .join() method. :smiley:


There are a bunch of helper methods available in the auto-suggestion list.

1 Like