我需要使用Koa和SuperAgent修补我需要的东西。 但是当我运行项目时,会引发错误。
代码
const Koa = require('koa');
// const request = require('request')
const superagent= require('superagent');
const app = new Koa();
app.use(async ctx => {
const res = await superagent.get('https://www.google.com');
ctx.body = res
})
app.listen(3000);
错误
Error: end() has already been called,so it's too late to start piping
at Response.response.pipe (F:\Project\Self_Project\Boxcc\node_modules\superagent\src\node\index.js:923:13)
at respond (F:\Project\Self_Project\Boxcc\node_modules\koa\lib\application.js:256:43)
at handleResponse (F:\Project\Self_Project\Boxcc\node_modules\koa\lib\application.js:164:34)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:20500) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(),Buffer.allocUnsafe(),or Buffer.from() methods instead.
Error: end() has already been called,so it's too late to start piping
at Response.response.pipe (F:\Project\Self_Project\Boxcc\node_modules\superagent\src\node\index.js:923:13)
at respond (F:\Project\Self_Project\Boxcc\node_modules\koa\lib\application.js:256:43)
at handleResponse (F:\Project\Self_Project\Boxcc\node_modules\koa\lib\application.js:164:34)
at process._tickCallback (internal/process/next_tick.js:68:7)