Add Jubility to table, fix Network bug with Error Codes

This commit is contained in:
Trenton Zimmer 2024-07-17 23:39:06 -04:00
parent bf8fb99ae5
commit 24a3499b33
2 changed files with 11 additions and 4 deletions

View File

@ -85,6 +85,7 @@ onMounted(async () => {
<h2 class="text-md">{{ song.songData.artist }}</h2>
</div>
<div>
<h2 class="text-lg">Jubility: {{ song.value / 10 }}</h2>
<h2 class="text-lg">Rate: {{ song.rate / 10 }}</h2>
</div>
</div>

View File

@ -74,10 +74,11 @@ export const useMainStore = defineStore("main", {
});
},
async callApi(endpoint, method = "GET", data = null) {
async callApi(endpoint, method = "GET", data = null, extraHeaders = {}) {
const apiServer = import.meta.env.VITE_API_URL;
const apiKey = import.meta.env.VITE_API_KEY;
let loadingTimeout;
this.errorCode = ""; // We want to reset the network error.
const startLoading = () => {
loadingTimeout = setTimeout(() => {
@ -90,11 +91,13 @@ export const useMainStore = defineStore("main", {
// Start loading after the specified delay
startLoading();
const headers = {
const baseHeaders = {
"App-Auth-Key": apiKey,
"User-Auth-Key": loadUserAuthKey(),
};
const headers = { ...baseHeaders, ...extraHeaders };
const url = `${apiServer}/v1${endpoint}`;
const config = {
@ -302,8 +305,11 @@ export const useMainStore = defineStore("main", {
async getMusicData(game, version, songIds = null, oneChart = false) {
try {
const data = await this.callApi(
`/music?game=${game}&version=${version}&songIds=${songIds.toString()}` +
(oneChart ? "&oneChart=true" : "")
`/music?game=${game}&version=${version}` +
(oneChart ? "&oneChart=true" : ""),
"GET",
null,
{ songIds: songIds.toString() }
);
return data.data;
} catch (error) {