下面的代码是我的谷歌脚本代码。当我简单地将url粘贴到浏览器上时,它将返回一个值。但是当我尝试使用javascript获取值时。它返回空值
谷歌脚本
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);
1条答案
按热度按时间kxkpmulp1#
使用method=“get”使用urlfetchapp.fetch()访问它,然后使用response.getcontenttext()获取返回。