nodemon启动后,浏览器访问loacalhost:3000,报错404
来源:2-8 深入理解async和await

慕侠8534226
2020-03-29
const Koa = require(‘koa’);
const app = new Koa();
app.use(async (ctx, next) => {
await next()
const res = ctx.res
console.log(“res”, res)
})
app.use(async (ctx, next) => {
const axios = require(‘axios’)
const res = await axios.get(‘http://7yue.pro’)
ctx.res = res;
await next()
})
app.listen(3000)
老师,这段代码nodemon启动后报错
Error: Request failed with status code 404
at createError (D:\project\island\node_modules\axios\lib\core\createError.js:16:15)
at settle (D:\project\island\node_modules\axios\lib\core\settle.js:18:12)
at IncomingMessage.handleStreamEnd (D:\project\island\node_modules\axios\lib\adapters\http.js:202:11)
at IncomingMessage.emit (events.js:215:7)
at endReadableNT (_stream_readable.js:1183:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
请问是怎么回事?
2回答
-
stone2019
2020-04-07
ctx.body给浏览器返回点东西试试
00 -
7七月
2020-03-30
提供的信息看不出来问题,请提供更多信息
00
相似问题