0

The code below is my google script code. When I simply paste the URL on the browser it is returning a value. but when I try to get the value using javascript. it returns null

Google script

function doGet(e) {
  var array = SpreadsheetApp.openById('1qwSU2YVuGea3Dg06yUpUkyhV1Hn-Qf3YshgZkEnJoBo')
  .getSheetByName('Sheet1').getRange('A1:A1').getValues();
  
  return ContentService.createTextOutput(array[0]);
}

Javascript

var url_string = "https://script.googleusercontent.com/macros/echo?user_content_key=1AxKHAUiqHNfdbnLALqbmxIoGLQuLR7qjSR7NxCDxgyqacFzuIovzOSyRyu0xkwpe7TF7qJcKknkuPYhV_apY6L9ikxPUB7em5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx_ryfhECjZEnMy8zAZf_PeEgqhQVTSu0Ty9Drtp1yaLkXH9-vnTbcP-gooKnCg3eBY8k9BT1tmvR4PZc_4F8_fJkoGWxUlugKqNYjOEVPmtwA&lib=M9OCNb7KeZyOBiWrcHIwQiTdKF1_8u-qf"; 
var url = new URL(url_string);
var c = url.searchParams.get("");
var c = url.
console.log(c);
alert(c);
2
  • I think you need to include the param you're searching for: var c = url.searchParams.get("lib") Worked in my test, at least Commented Jul 8, 2021 at 19:25
  • Do you plan to use apps script IDE to get the return value of your url? Commented Jul 8, 2021 at 21:25

1 Answer 1

1

Access it with UrlFetchApp.fetch() using method = "Get" and then use response.getContentText() to get the return.

Sign up to request clarification or add additional context in comments.

Comments

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.