This commit is contained in:
NoLogicAlan committed 2026-05-09 23:55:19 +03:00
1 parent 8ac0dde343
commit 71b79e7f38
1 file changed
+4 -1
+4 -1
View File
@@ -39,8 +39,11 @@ function buildSignature(params, apiSecret) {
* @returns {Promise<object>} Parsed JSON response * @returns {Promise<object>} Parsed JSON response
*/ */
async function apiCall(params, apiSecret, post = false) { async function apiCall(params, apiSecret, post = false) {
const allParams = { ...params, format: "json" }; // Per Last.fm spec: format must NOT be included in the signature.
// See: https://www.last.fm/api/authspec#_8-signing-calls
const allParams = { ...params };
allParams.api_sig = buildSignature(allParams, apiSecret); allParams.api_sig = buildSignature(allParams, apiSecret);
allParams.format = "json"; // add AFTER signature
const url = post ? BASE_URL : `${BASE_URL}?${new URLSearchParams(allParams)}`; const url = post ? BASE_URL : `${BASE_URL}?${new URLSearchParams(allParams)}`;