Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

Nodejs/koa: 'ECONNREFUSED 127.0.0.1:80 '

$
0
0

我运行如下代码会报ECONNREFUSED 127.0.0.1:80的错误, 但是当我把request的url从’/api’改成’http://localhost:3001/api’ 就不会有错了。。。求指导求教育

const Koa = require('koa');
const router = require('koa-router')();
const request = require('superagent');

const app = new Koa();
router.get('/', ctx=>{
    ctx.body='hello'
})
router.get('/api', ctx=>{
  ctx.body = 'tttttttt'
})

app.use(router.routes());
app.use(router.allowedMethods());

request.get('/api').then((data)=>{
      console.log(data)
})

app.listen(3001)

Viewing all articles
Browse latest Browse all 14821

Trending Articles