From 24a3499b33d40effb35b4d3204075fd6dc3da4a9 Mon Sep 17 00:00:00 2001
From: Trenton Zimmer <66042448+trmazi@users.noreply.github.com>
Date: Wed, 17 Jul 2024 23:39:06 -0400
Subject: [PATCH] Add Jubility to table, fix Network bug with Error Codes
---
src/components/Tables/JubilityTable.vue | 1 +
src/stores/main.js | 14 ++++++++++----
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/components/Tables/JubilityTable.vue b/src/components/Tables/JubilityTable.vue
index 2285cc3..6a96b86 100644
--- a/src/components/Tables/JubilityTable.vue
+++ b/src/components/Tables/JubilityTable.vue
@@ -85,6 +85,7 @@ onMounted(async () => {
{{ song.songData.artist }}
+
Jubility: {{ song.value / 10 }}
Rate: {{ song.rate / 10 }}
diff --git a/src/stores/main.js b/src/stores/main.js
index b0cc68f..29ebd49 100644
--- a/src/stores/main.js
+++ b/src/stores/main.js
@@ -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) {