This commit is contained in:
Timothy Jaeryang Baek
2026-07-24 01:44:30 -04:00
parent b6acd3cc45
commit 212eec408c
10 changed files with 440 additions and 10 deletions
+56
View File
@@ -440,6 +440,62 @@ export const updateUserInfo = async (token: string, info: object) => {
return res;
};
export const getUserVariables = async (token: string) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/users/user/variables`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
}
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((err) => {
console.error(err);
error = err.detail;
return null;
});
if (error) {
throw error;
}
return res;
};
export const updateUserVariables = async (token: string, variables: Record<string, string>) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/users/user/variables/update`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
},
body: JSON.stringify({
variables
})
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((err) => {
console.error(err);
error = err.detail;
return null;
});
if (error) {
throw error;
}
return res;
};
export const getAndUpdateUserLocation = async (token: string) => {
const location = await getUserPosition().catch((err) => {
console.error(err);