1

I need to use Koa and SuperAgent to patch something I need. But when I run my project, the error is thrown.

The code

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);

The error

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)
Mathon
  • 13
  • 3

0 Answers0