const Router = require(‘koa-router’)
const router = new Router()
const axios = require(‘axios’)
const getAccessToken = require(’…/utils/getAccessToken.js’)
router.get(’/list’, async (ctx, next) => {
//查询歌单列表
const ACCESS_TOKEN = await getAccessToken()
const ENV = 'test-6golf8e0c24e8273’
const url = https://api.weixin.qq.com/tcb/invokecloudfunction?access_token=${ACCESS_TOKEN}&env=${ENV}&name=music
const data = await axios({
url,
method: ‘post’,
data: {
$url: ‘playlist’,
start: 0,
count: 50
}
}).then((res) => {
console.log(res.data)
return res.data
}).catch((error) => {
console.log(error)
})
ctx.body = {
data,
code:20000
}
})
module.exports = router