How to read url params in custom created nodes

I’m passing some values in the URL, and all I want to do is read those values in a custom node for some automated process. Quick help will be appreciated. Thanks in advance.

Hey @yasin.tahasildar,

What do you mean? Do you have an example you can share?

Hi @Jon
I am trying to read an abc url params value inside custom node logic

URL: https://localhost:5678?abc=sjsbsjkbsk

I tried following approaches in order to get

 const url = require('url');
const queryString = window.location.search; 
let params = new url.URLSearchParams(queryString );
params.get('abc')

it’s not identifying window keyword

I am adding this logic in side

export class mycustomnode  implements INodeType {
  description:INodeTypeDescription = {
  }

  methods = {
		loadOptions: {
    async getSomeName(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
         const url = require('url');
        const queryString = window.location.search; 
       let params = new url.URLSearchParams(queryString );
       params.get('abc')
     }
    }
  }
}

Hey @yasin.tahasildar,

The node won’t have access to the browser as it doesn’t run there, Nodes run in the server side process and the front end service displays them. I suspect this will be the problem you have, I believe Praveen had a similar issue when trying to use Session Storage.

Hi @Jon, Yes, me and Praveen are on the same page.

As per the suggestion on different thread, I am trying read value from env file inside node with following command

$env['USER_TOKEN']

 $env is throwing error as not defiend

Also i tried

process.env.USER_TOKEN

undefined value is coming 

I am reading values from .env file

Hey @yasin.tahasildar,

Are you using $env in the node or in the code for the node? If it is in the node code it may not work if you are trying to use it as a variable but if it is for a user input it might work with {{$env['USER_TOKEN']}} which would set a default value.

Hey @Jon

In our custom node, we have multiple dropdowns and their values are coming from APIs

In the rest API, we want to pass token and host_name either by env or any browser level storages, this logic is an inside the method declaration of the custom node.

any suggestion on how we can get host_ip in inside custom node methods

Hey @yasin.tahasildar,

What happened when you tried to use process.env.XXX did you try to output the value to see if it was set?