Move API_ORIGIN into constants.js
This commit is contained in:
@@ -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 list() {
|
||||
let result;
|
||||
try {
|
||||
result = await fetcher.get(`${origin}/api/v1/volumes`, { access_token: accessToken });
|
||||
result = await fetcher.get(`${API_ORIGIN}/api/v1/volumes`, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
return [e];
|
||||
}
|
||||
@@ -21,7 +21,7 @@ function create() {
|
||||
async getStatus(id) {
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.get(`${origin}/api/v1/volumes/${id}/status`, { access_token: accessToken });
|
||||
result = await fetcher.get(`${API_ORIGIN}/api/v1/volumes/${id}/status`, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
@@ -36,7 +36,7 @@ function create() {
|
||||
async remount(id) {
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.post(`${origin}/api/v1/volumes/${id}/remount`, {}, { access_token: accessToken });
|
||||
result = await fetcher.post(`${API_ORIGIN}/api/v1/volumes/${id}/remount`, {}, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
@@ -46,7 +46,7 @@ function create() {
|
||||
async add(name, mountType, mountOptions) {
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.post(`${origin}/api/v1/volumes`, { name, mountType, mountOptions }, { access_token: accessToken });
|
||||
result = await fetcher.post(`${API_ORIGIN}/api/v1/volumes`, { name, mountType, mountOptions }, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ function create() {
|
||||
async update(id, mountOptions) {
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.post(`${origin}/api/v1/volumes/${id}`, { mountOptions }, { access_token: accessToken });
|
||||
result = await fetcher.post(`${API_ORIGIN}/api/v1/volumes/${id}`, { mountOptions }, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
@@ -66,7 +66,7 @@ function create() {
|
||||
async remove(id) {
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.del(`${origin}/api/v1/volumes/${id}`, { access_token: accessToken });
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/volumes/${id}`, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ function create() {
|
||||
async getBlockDevices() {
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.get(`${origin}/api/v1/system/block_devices`, { access_token: accessToken });
|
||||
result = await fetcher.get(`${API_ORIGIN}/api/v1/system/block_devices`, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user