【问题标题】:Google Closure Compiler warns of "expressions are not callable"Google Closure Compiler 警告“表达式不可调用”
【发布时间】:2018-01-15 10:53:53
【问题描述】:

在以下代码中,我收到警告:

表达式不可调用

我正在使用 Google Closure 编译器。当请求对象作为函数调用时会出现警告。我怎样才能摆脱这个警告?

var request = require('request'); // See https://github.com/request/request

request({
    url: "https://www.googleapis.com/oauth2/v4/token",
    method: "POST",
    json: false,
    body: tokenPostData,
    headers: {
        "content-type": "application/x-www-form-urlencoded"
    },
}, function (error, response, body) {

});

【问题讨论】:

    标签: google-closure-compiler


    【解决方案1】:

    想出了解决办法。只需在请求对象后添加“call”,并确保第一个参数值为“this”即可。

    var request = require('request'); // See https://github.com/request/request
    
    request.call(this, {
        url: "https://www.googleapis.com/oauth2/v4/token",
        method: "POST",
        json: false,
        body: tokenPostData,
        headers: {
            "content-type": "application/x-www-form-urlencoded"
        },
    }, function (error, response, body) {
    
    });
    

    【讨论】:

      猜你喜欢
      • 2011-09-04
      • 1970-01-01
      • 1970-01-01
      • 2019-09-27
      • 2016-02-27
      • 1970-01-01
      • 2014-10-15
      • 2011-05-12
      • 1970-01-01
      相关资源
      最近更新 更多