如何从 javascript 中 google 脚本 url 的值中获取 return
How to get return from value from a google script url in javascript
下面的代码是我的google脚本代码。当我简单地将 URL 粘贴到浏览器时,它会返回一个值。但是当我尝试使用 javascript 获取值时。它 returns 无效
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);
使用 method = "Get" 通过 UrlFetchApp.fetch() 访问它,然后使用 response.getContentText() 获取 return.
下面的代码是我的google脚本代码。当我简单地将 URL 粘贴到浏览器时,它会返回一个值。但是当我尝试使用 javascript 获取值时。它 returns 无效
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);
使用 method = "Get" 通过 UrlFetchApp.fetch() 访问它,然后使用 response.getContentText() 获取 return.