首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RequestError:错误:阅读ECONNRESET

RequestError:错误:阅读ECONNRESET
EN

Stack Overflow用户
提问于 2018-01-03 19:17:25
回答 1查看 15.9K关注 0票数 1

我尝试使用nba.com api,但是给出了这个错误。

" RequestError :错误:在新的RequestError上阅读ECONNRESET,在Request.plumbing.callback,RequestError,at Request.RP$callback,callback at self.callback (c:\Users\Omer\Desktop\game\node_modules\request( (c:\Users\Omer\Desktop\game\node_modules\request\request.js:884:8) at emitOne (events.js:116:13) at ClientRequest.emit (events.js:211:7) at TLSSocket.socketErrorListener (_http_client.js:387:9 )) emitOne (events.js:116:13) at TLSSocket.emit (events.js:211:7) at emitErrorNT (Desktop/streams/deady.js:64:8),_combinedTickCallback (Desktop/process/next_tick.js:138:11),process._tickCallback (Desktop/process/next_tick.js:180:9),与以前的事件相比: at Request.plumbing.init (c:\User\Omer\Desktop\game\node)_modules\request-promise-core\lib\plumbing.js:36:28) at Request.RP$initInterceptor as init应新请求(c:\Users\Omer\Desktop\game\node_modules\request\request.js:130:8)应请求(c:\Users\Omer\Desktop\game\node_modules\request\index.js:54:10) at requestStats (c:\Users\Omer\Desktop\game\modules\utils\crawlers\stats\nba.stats( (c:\Users\Omer\Desktop\game\modules\utils\crawlers\stats\nba.stats.crawler.js:12:12) at Object.crawl (c:\Users\Omer\Desktop\game\modules\utils\crawlers\stats\stats.crawler.js:20:20) at Object.runCrawl (c:\Users\Omer\Desktop\game\modules\utils\crawlers\utils.crawler.js:27:18) )(c:\Users\Omer\Desktop\game\scripts\useful\crawl.js:19:13) at loadConfig (c:\Users\Omer\Desktop\game\scripts\useful\crawl.js:12:5) at c:\Users\Omer\Desktop\game\config\lib\mongoose.js:35:21 at process._tickCallback (tick.js/process/next_tick.js:188:7)“

我的密码是:

代码语言:javascript
复制
    var path = require('path'),
    request = require('request-promise'),
    format = require('string-template');

module.exports = {
    crawl: crawl
};

const STATS_NBA_API = 'http://stats.nba.com/stats/leaguegamelog?Counter=1000&DateFrom=&DateTo=&Direction=DESC&LeagueID=00&PlayerOrTeam=P&Season=2017-18&SeasonType=Regular+Season&Sorter=DATE';

function crawl(options){
    return requestStats(STATS_NBA_API)
        .then(statsPlayers => { return convertStatsToList(statsPlayers); })
        .catch(error => 
            console.log(error))
}

function convertStatsToList(statsPlayers){
    console.log(statsPlayers)
}

function requestStats(url){
    var options = {
        method: 'GET',
        url: url,
        json: true       
    };
    return request(options);
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-01-04 19:56:47

代码语言:javascript
复制
   function requestStats(url) {
    var options = {
        method: 'GET',
        url: url,
        json: true,
        headers: {
            'Connection': 'keep-alive',
            'Accept-Encoding': '',
            'Accept-Language': 'en-US,en;q=0.8'
        }
    };
    return request(options);
}
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48083781

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档