在Node.js中发送get请求时获取HPE_INVALID_TOKEN_ERROR

时间:2016-08-08 03:46:32

标签: javascript node.js request

此代码昨天/今天早些时候完美无缺,现在它响应空响应和正文以及请求回调错误中的HPE_INVALID_TOKEN_ERROR。我真的不知道该怎么做。

this.getVerifyAge = () => {
    return new Promise((resolve, reject) => {
        let url = 'https://example.org/api/';
        //let url = 'https://www.google.ca'
        let headers = {
            'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
            'Accept-Encoding': 'gzip, deflate, sdch, br',
            'Accept-Language': 'fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4',
            'Connection': 'keep-alive',
            'Host': 'club.pokemon.com',
            'Upgrade-Insecure-Requests': '1',
            'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36'
        };
        var options = {
            url: url,
            //headers: headers,
            jar: this.j
        }
        if (this.proxy) {
            options.proxy = this.proxy;
        }
        request(options, (error, response, body) => {
            if (error || response.statusCode === 502) {
                reject(new Error('ERROR : getVerifyAge'));
            }
            else {

            }
        });
    });
}

0 个答案:

没有答案