getting URL parameters in js file

Hi,

How can I get the URL parameters when calling a js file saved in web/scripts?

Thanks,
Tal

Hi Tal,

Try this:

request.query.PARAMETERNAME

Where PARAMETERNAME is the actual parameter.

Mark

this is not working:

var clk = request.query.clk;


var userAcquisitionRedirectsItem = new UserAcquisitionRedirectsItem( { adNetwork : 'archy', appId : 'appId', clickId : clk, country : 'IL', userAdvertisingId : '1234-afjad-test', userIp : '192.168.1.144' });

after this code I see in the table all the values, except for clickId which is empty

How do you send the parameter in the URL?

https://api.backendless.com/app_id/v1/files/web/scripts/UserAcquisitionRedirect/archyRedirect.js?clk=123

Is it a GET or POST request?

I’m pasting this url in a browser

Well, I just did a simple test and it is working as expected. Here’s a URL to try:

https://api.backendless.com/91186007-E09C-8561-FF0E-ADCD410BF400/v1/files/web/scripts/hello.js?test=foo

Here’s the source code of the script:

exports.run = function ( request, response )
{
    response.send( "value of the test parameter is: " + request.query.test );
};

It seems like the problem would be somewhere in your code.

Regards,
Mark

thanks mark, found my error