我运行如下代码会报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)