also

also

router.get('/string', async (ctx, next) => {
  let a = await axios.get('http://localhost:1111/comments')   // Get the backend interface 
  console.log('a' ,a);
  let obj = {
    'name': 'kang',
    'age': 24
  }
  ctx.body = a.data    // provided to front-end access http://xxx:3000/string 
})

cross domain

const cors = require('koa2-cors')    // Provide an interface to the front end to solve cross-domain 
app.use(cors())   // cross-domain

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325239221&siteId=291194637