mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-07-07 00:12:07 +08:00
rewrite unit tests
This commit is contained in:
29
util/util.js
29
util/util.js
@ -84,34 +84,7 @@ function createWebAPIRequest(
|
||||
});
|
||||
}
|
||||
|
||||
function createRequest(path, method, data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const options = {
|
||||
url: `http://music.163.com${path}`,
|
||||
method: method,
|
||||
headers: {
|
||||
"Referer": "http://music.163.com",
|
||||
"Cookie": "appver=1.5.2",
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"User-Agent": randomUserAgent()
|
||||
}
|
||||
};
|
||||
|
||||
if (method.toLowerCase() === "post") {
|
||||
options.body = data;
|
||||
}
|
||||
|
||||
request(options, function(error, res, body) {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve(body);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
module.exports = {
|
||||
request,
|
||||
createWebAPIRequest,
|
||||
createRequest
|
||||
createWebAPIRequest
|
||||
};
|
||||
|
Reference in New Issue
Block a user