【问题标题】:ReferenceError: logger is not defined (Google Sheets / App Script)ReferenceError:未定义记录器(Google 表格/应用程序脚本)
【发布时间】:2020-09-11 17:51:28
【问题描述】:

为什么会出现这个错误?

ReferenceError: 未定义记录器(第 4 行)

function myFunction() {
  var res = UrlFetchApp.fetch("https://api.cartolafc.globo.com/mercado/destaques");
  var content = res.getContentText();
  logger.log(res);
  logger.log(content);
}

【问题讨论】:

    标签: javascript google-apps-script google-sheets


    【解决方案1】:

    改用Logger.log

    Logger 是类的名称,log 是该类的方法。 google 脚本中没有名为 logger 的内置类。

    如果您启用了 V8,您也可以使用 console.log

    查看详情here

    【讨论】:

    • console.log 完美解决方案,谢谢队友!我正在等待 5 分钟来标记您对我的问题的解决方案的回答!
    • @BrondbyIF 很高兴它有帮助。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-31
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 2021-06-04
    • 1970-01-01
    相关资源
    最近更新 更多