2017-08-22 2 views
0
function getStuff(req: express.Request, res: express.Response, next: express.NextFunction): void { 
    fetch('http://localhost:3000/stuff') 
     .then((data: {}) => { 
      res.send(data.body._readableState.buffer.head.data.toString()); 
     }) 
     .catch((err: {}) => { 
      res.json(err); 
     }); 
} 

に私が取得していますエラーが[tslint] Forbidden http url in string 'http://localhost:3000/stuff' (no-http-string)tslint:禁断のHTTP URL文字列

である私は、このエラーはfetch()法上// tslint:disable-next-lineを置くことによって無視され得ることもできますが、これに他の解決策はありますか?このルールの

答えて

1

説明Do not use strings that start with 'http:'. URL strings should start with 'https:'.

1)一行

2の検査を無効にするfetch()方法上方// tslint:disable-next-line:no-http-stringを入れて)すべてのプロジェクトのための検査を無効にするtslint.json

{ 
    "rules": { 
     "no-http-string": false, // <---- this line 
    } 
} 

を入れ