Move API_ORIGIN into constants.js

This commit is contained in:
Johannes Zellner
2025-03-03 11:22:56 +01:00
parent 6c674e86e5
commit ef0a9a4a1e
37 changed files with 196 additions and 217 deletions
+5 -5
View File
@@ -1,15 +1,15 @@
import { fetcher } from 'pankow';
import { API_ORIGIN } from '../constants.js';
function create() {
const accessToken = localStorage.token;
const origin = import.meta.env.VITE_API_ORIGIN || window.location.origin;
return {
async info() {
let error, result;
try {
result = await fetcher.get(`${origin}/api/v1/updater/updates`, { access_token: accessToken });
result = await fetcher.get(`${API_ORIGIN}/api/v1/updater/updates`, { access_token: accessToken });
} catch (e) {
error = e;
}
@@ -20,7 +20,7 @@ function create() {
async getAutoupdatePattern() {
let error, result;
try {
result = await fetcher.get(`${origin}/api/v1/updater/autoupdate_pattern`, { access_token: accessToken });
result = await fetcher.get(`${API_ORIGIN}/api/v1/updater/autoupdate_pattern`, { access_token: accessToken });
} catch (e) {
error = e;
}
@@ -31,7 +31,7 @@ function create() {
async setAutoupdatePattern(pattern) {
let error, result;
try {
result = await fetcher.post(`${origin}/api/v1/updater/autoupdate_pattern`, { pattern }, { access_token: accessToken });
result = await fetcher.post(`${API_ORIGIN}/api/v1/updater/autoupdate_pattern`, { pattern }, { access_token: accessToken });
} catch (e) {
error = e;
}
@@ -42,7 +42,7 @@ function create() {
async check() {
let error, result;
try {
result = await fetcher.post(`${origin}/api/v1/updater/check_for_updates`, {}, { access_token: accessToken });
result = await fetcher.post(`${API_ORIGIN}/api/v1/updater/check_for_updates`, {}, { access_token: accessToken });
} catch (e) {
error = e;
}