0
app.get('/mypath', function (req, res) {
            var url_parts = url.parse(req.url, true);
            var query = url_parts.query;
            var param1Value = param1Value;
            var param2Value = param2Value;
            console.log(req.query)
            res.redirect("/mypath/js/index.js?param1="+param1Value+"&param2="+param2Value+"")
    });

As seen above, I can successfully redirect the URL along with the query string.

However, the flow over here is a little different.

There is a web page hosted on https://www.somewebpage.com where I'm including a JavaScript in the following way.

<script type="text/javascript" async="" src="https://abcd/myscript.js"></script>

myscript.js is located on another server where I call it using res.redirect

My problem is that I want to receive the query string params in myscript.js file. How do I do that?

moon
  • 640
  • 6
  • 14
Vivek Malhotra
  • 751
  • 2
  • 7
  • 17
  • just a thought; in somewebpage.com can u fetch the querystring, store it in locastorage and then access it when needed (in myscript.js); give it a shot and let me if it works – Rajkumar Somasundaram Dec 04 '17 at 07:20
  • Possible duplicate of [How can I get query string values in JavaScript?](https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript) – Vipin Kumar Dec 04 '17 at 07:22
  • Actually, somewebpage.com is a shopify page where I'm loading my custom JS. Hence I can't do anything on it. Basically, my main target is to pass data to `myscript.js` which I'm loading inside shopify's theme. – Vivek Malhotra Dec 04 '17 at 07:24

0 Answers0