Move API_ORIGIN into constants.js
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
|
||||
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 {
|
||||
name: 'TokensModel',
|
||||
async list() {
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.get(`${origin}/api/v1/tokens`, { access_token: accessToken });
|
||||
result = await fetcher.get(`${API_ORIGIN}/api/v1/tokens`, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
@@ -21,7 +21,7 @@ function create() {
|
||||
async add(name, scope) {
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.post(`${origin}/api/v1/tokens`, { name, scope }, { access_token: accessToken });
|
||||
result = await fetcher.post(`${API_ORIGIN}/api/v1/tokens`, { name, scope }, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
@@ -32,7 +32,7 @@ function create() {
|
||||
async remove(id) {
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.del(`${origin}/api/v1/tokens/${id}`, { access_token: accessToken });
|
||||
result = await fetcher.del(`${API_ORIGIN}/api/v1/tokens/${id}`, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user