Move API_ORIGIN into constants.js
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
|
||||
import { fetcher } from 'pankow';
|
||||
import DomainsModel from './DomainsModel.js';
|
||||
import { API_ORIGIN } from '../constants.js';
|
||||
|
||||
function create() {
|
||||
const accessToken = localStorage.token;
|
||||
const origin = import.meta.env.VITE_API_ORIGIN || window.location.origin;
|
||||
|
||||
const domainsModel = DomainsModel.create();
|
||||
|
||||
@@ -15,7 +15,7 @@ function create() {
|
||||
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.get(`${origin}/api/v1/archives`, { page, per_page, access_token: accessToken });
|
||||
result = await fetcher.get(`${API_ORIGIN}/api/v1/archives`, { page, per_page, access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
@@ -26,7 +26,7 @@ function create() {
|
||||
async remove(id) {
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.del(`${origin}/api/v1/archives/${id}`, { access_token: accessToken });
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/archives/${id}`, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ function create() {
|
||||
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.post(`${origin}/api/v1/archives/${id}/unarchive`, data, { access_token: accessToken });
|
||||
result = await fetcher.post(`${API_ORIGIN}/api/v1/archives/${id}/unarchive`, data, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user