当我使用SuperAgent&Koa修补程序并发送数据时,会引发错误

我需要使用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)
bobostst 回答:当我使用SuperAgent&Koa修补程序并发送数据时,会引发错误

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2900561.html

大家都在问