0

I'd like to add a parameter after an URL in a Javascript function. The full URL I'd like to have is: https://my-url.com/section1/section2/here_a_random_number.json?lang=en This is the ".json?lang=en" that I'd like to add at the end of the URL.

Here my function (in a Google script, linked to a sheet):

  function myfunction(randomnumber) {
  var myUrl = "https://my-url.com/section1/section2/" + escape(randomnumber);
  var jsonData = UrlFetchApp.fetch(myUrl);
  var jsonString = jsonData.getContentText();
  var jsonObject = JSON.parse(jsonString).result;
  var name = (jsonObject.name);
  Utilities.sleep(2000);
return name;
}

Where could I put/add my language parameter ?

1
  • So what is the problem? Commented Feb 16, 2015 at 15:53

2 Answers 2

1

Just add it to the end of the URL:

var myUrl = "https://my-url.com/section1/section2/" + escape(randomnumber) + ".json?lang=en";
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot ! It works ! :) (Sorry if my question was stupid but it's the first I use programmation language)
1

try to replace

var myUrl = "https://my-url.com/section1/section2/" + escape(randomnumber); 

by var myUrl = "https://my-url.com/section1/section2/" + escape(randomnumber)+".json?lang=en";

1 Comment

Thanks a lot ! It works ! :) (Sorry if my question was stupid but it's the first I use programmation language)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.