修复酷我源搜索提示、排行榜接口挂掉的问题

This commit is contained in:
lyswhut
2019-10-28 22:42:01 +08:00
parent 1bd8694262
commit 63a5f94a67
4 changed files with 54 additions and 9 deletions
+12
View File
@@ -1,2 +1,14 @@
import { httpGet } from '../../request'
export const formatSinger = rawData => rawData.replace(/&/g, '、')
export const matchToken = headers => headers['set-cookie'][0].match(/kw_token=(\w+)/)[1]
export const getToken = () => new Promise((resolve, reject) => {
httpGet('http://www.kuwo.cn', (err, resp) => {
if (err) return reject(err)
if (resp.statusCode != 200) return reject(new Error('获取失败'))
const token = matchToken(resp.headers)
resolve(token)
})
})