这是代码,做转发用的,但是ctx.response.body会前端的是404
router.get('/getData', async (ctx, next) => { let opts = Object.keys(ctx.query).reduce((pre, item, index) => { return pre += `${item}=${encodeURIComponent(ctx.query[item])}&` }, '?') // const getData = await request.get(`https://searchapi.hc360.com/getmmtlast.cgi${opts}`) // console.log('getData', getData.query); request({ url: `https://searchapi.hc360.com/getmmtlast.cgi${opts}`, method: 'GET', encoding: null }, function(err, res, data) { if (!err && res.statusCode == 200) { console.log('data', Iconv.decode(data, 'gbk')); ctx.response.body = Iconv.decode(data, 'gbk') } else ctx.response.body = err; }) await next(); })
慕的地6264312
相关分类