接口一:
testCnode().then((res) => {
console.log("res2", res);
});
接口二:
let str =
"ct=24&qqmusic_ver=1298&new_json=1&remoteplace=txt.yqq.song&searchid=69020128776265001&t=0&aggr=1&cr=1&catZhida=1&lossless=0&flag_qc=0&p=1&n=10&w=%E5%91%A8%E6%9D%B0&g_tk_new_20200303=5381&g_tk=5381&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8¬ice=0&platform=yqq.json&needNewCode=0";
let params = {};
str.split("&").map((ele) => {
let arr = ele.split("=");
params[arr[0]] = arr[1];
});
params.w = "周杰伦";
params.n = "10";
fetchQqMusic(params).then((res) => {
console.log("res,res", res);
});
当这两个接口放在一起的时候,执行结果如下 : 如果想要先打印res2,再打印res,解决方式如下 [用到async await 语法糖]:
async init() {
await testCnode().then((res) => {
console.log("res2", res);
});
let str =
"ct=24&qqmusic_ver=1298&new_json=1&remoteplace=txt.yqq.song&searchid=69020128776265001&t=0&aggr=1&cr=1&catZhida=1&lossless=0&flag_qc=0&p=1&n=10&w=%E5%91%A8%E6%9D%B0&g_tk_new_20200303=5381&g_tk=5381&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8¬ice=0&platform=yqq.json&needNewCode=0";
let params = {};
str.split("&").map((ele) => {
let arr = ele.split("=");
params[arr[0]] = arr[1];
});
params.w = "周杰伦";
params.n = "10";
fetchQqMusic(params).then((res) => {
console.log("res,res", res);
});
},
|