static async sendRequest(location, method, values) {

		// If we're already sending, return an object that can be read by the Popup
		if(Api.isSending === true) { return { code: 1, error: "There is still a request that is not processed, please wait..." }; }
		Api.isSending = true;

		// Send a request and return the result
		const response = await fetch(encodeURI(VALUES.api + location), {
			method,
			headers: {
				"Content-Type": "application/json",
				"Authorization": (Api.TOKEN && Api.TOKEN.jwt ? "Bearer " + Api.TOKEN.jwt : "")
			},
			body: ((values && method !== "GET") ? JSON.stringify(values) : null)
		});

		// Get the response
		Api.isSending = false;
		const res = await response.json();

		// Show error popup for rate limiting
		if(res.code === 429) {
			Popup.show(res.error, "error");
		}



		// If the token is expired, redirect to login screen with error
		if(res.error && res.error.includes("expired")) {
			window.location.href = VALUES.assets + "php/redirect.php?redirect=&code=400&message=Your%20session%20expired.%20Please%20login%20again%20to%20continue.";
		}

		// Set the token if it's provided
		if(res.jwt) {
			Api.TOKEN = new JWT(res.jwt);
			document.cookie = "jwt=" + res.jwt + "; Expires=" + Date.now() + 3600 + "; Path=/";
		}

		// Return the result
		return res;

	}
/**
	 * Sends a request to the Spotify Labelling API
	 * 
	 * @param {string} location The action of the request
	 * @param {string} method The method of the request 
	 * @param {object} values The values in an object so it will be received as an associative array
	 * @returns {object} The return object
	 */
Sends a request to the Spotify Labelling API

@param {string} location The action of the request
@param {string} method The method of the request
@param {object} values The values in an object so it will be received as an associative array
@returns {object} The return object
Sends a request to the Spotify Labelling API @param { string } location The action of the request @param { string } method The method of the request @param { object } values The values in an object so it will be received as an associative array @returns { object } The return object
static async sendRequest(location, method, values) {
		if(Api.isSending === true) { return { code: 1, error: "There is still a request that is not processed, please wait..." }; }
		Api.isSending = true;
		const response = await fetch(encodeURI(VALUES.api + location), {
			method,
			headers: {
				"Content-Type": "application/json",
				"Authorization": (Api.TOKEN && Api.TOKEN.jwt ? "Bearer " + Api.TOKEN.jwt : "")
			},
			body: ((values && method !== "GET") ? JSON.stringify(values) : null)
		});
		Api.isSending = false;
		const res = await response.json();
		if(res.code === 429) {
			Popup.show(res.error, "error");
		}
		if(res.error && res.error.includes("expired")) {
			window.location.href = VALUES.assets + "php/redirect.php?redirect=&code=400&message=Your%20session%20expired.%20Please%20login%20again%20to%20continue.";
		}
		if(res.jwt) {
			Api.TOKEN = new JWT(res.jwt);
			document.cookie = "jwt=" + res.jwt + "; Expires=" + Date.now() + 3600 + "; Path=/";
		}
		return res;
	}
static async sendRequest ( location , method , values ) { if ( Api . isSending === true ) { return { code : 1 , error : "There is still a request that is not processed, please wait..." } ; } Api . isSending = true ; const response = await fetch ( encodeURI ( VALUES . api + location ) , { method , headers : { "Content-Type" : "application/json" , "Authorization" : ( Api . TOKEN && Api . TOKEN . jwt ? "Bearer " + Api . TOKEN . jwt : "" ) } , body : ( ( values && method !== "GET" ) ? JSON . stringify ( values ) : null ) } ) ; Api . isSending = false ; const res = await response . json ( ) ; if ( res . code === 429 ) { Popup . show ( res . error , "error" ) ; } if ( res . error && res . error . includes ( "expired" ) ) { window . location . href = VALUES . assets + "php/redirect.php?redirect=&code=400&message=Your%20session%20expired.%20Please%20login%20again%20to%20continue." ; } if ( res . jwt ) { Api . TOKEN = new JWT ( res . jwt ) ; document . cookie = "jwt=" + res . jwt + "; Expires=" + Date . now ( ) + 3600 + "; Path=/" ; } return res ; }
Sends a request to the Spotify Labelling API
Sends a request to the Spotify Labelling API
// If we're already sending, return an object that can be read by the Popup // Send a request and return the result // Get the response // Show error popup for rate limiting // If the token is expired, redirect to login screen with error // Set the token if it's provided // Return the result