Google Closure Compiler警告"表达式不可调用"

时间:2018-01-15 10:53:53

标签: google-closure-compiler

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

  

表达式不可调用

我正在使用Google Closure Compiler。将请求对象作为函数调用时会发出警告。我怎样才能摆脱这个警告?

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) {

});

1 个答案:

答案 0 :(得分:0)

找出解决方案。只需在请求对象后添加“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) {

});