Should I use .getContentText() in this Google Script GET request?(我应该在这个 Google Script GET 请求中使用 .getContentText() 吗?)
问题描述
这两个似乎都返回并记录相同的事情.使用哪个重要吗?第一个示例是 文档.
Both of these appear to return and log the same thing. Does it matter which is used? The first example is what's shown on the documentation.
var rawCalendar1 = UrlFetchApp.fetch("https://example.com/blog/events.ics");
Logger.log(rawCalendar1.getContentText());
var rawCalendar2 = UrlFetchApp.fetch("https://example.com/blog/events.ics");
Logger.log(rawCalendar2);
推荐答案
UrlFetchApp.fetch() 的返回类型是 HttpResponse.在您的示例中,您可以在 rawCalendar1 上调用多个方法来检查返回值.
Return type for UrlFetchApp.fetch() is HttpResponse. In your example, you can call several methods on rawCalendar1 to inspect the returned value.
请参阅 https://developers.google.com/应用程序脚本/参考/url-fetch/http-response
getContentText() 将 HttpResponse 的内容转换为字符串"类型.同样,Logger.log() 将括号之间的内容转换为字符串",这与在其上调用 getContentText() 基本相同.
getContentText() converts the contents of HttpResponse to type 'string'. Likewise, Logger.log() casts what is between the brackets to 'string', which is essentially the same as calling getContentText() on it.
这篇关于我应该在这个 Google Script GET 请求中使用 .getContentText() 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我应该在这个 Google Script GET 请求中使用 .getContentText() 吗?


基础教程推荐
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 直接将值设置为滑块 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01