1
1
import store from "@/store" ;
2
2
import router from "@/router" ;
3
3
import { Base64 } from "js-base64" ;
4
- import { fetchURL } from "@/api/ utils" ;
4
+ import { baseURL } from "@/utils/constants " ;
5
5
6
6
export function parseToken ( token ) {
7
7
const parts = token . split ( "." ) ;
@@ -32,17 +32,13 @@ export async function validateLogin() {
32
32
export async function login ( username , password , recaptcha ) {
33
33
const data = { username, password, recaptcha } ;
34
34
35
- const res = await fetchURL (
36
- `/api/login` ,
37
- {
38
- method : "POST" ,
39
- headers : {
40
- "Content-Type" : "application/json" ,
41
- } ,
42
- body : JSON . stringify ( data ) ,
35
+ const res = await fetch ( `${ baseURL } /api/login` , {
36
+ method : "POST" ,
37
+ headers : {
38
+ "Content-Type" : "application/json" ,
43
39
} ,
44
- false
45
- ) ;
40
+ body : JSON . stringify ( data ) ,
41
+ } ) ;
46
42
47
43
const body = await res . text ( ) ;
48
44
@@ -54,7 +50,7 @@ export async function login(username, password, recaptcha) {
54
50
}
55
51
56
52
export async function renew ( jwt ) {
57
- const res = await fetchURL ( ` /api/renew`, {
53
+ const res = await fetch ( ` ${ baseURL } /api/renew`, {
58
54
method : "POST" ,
59
55
headers : {
60
56
"X-Auth" : jwt ,
@@ -73,17 +69,13 @@ export async function renew(jwt) {
73
69
export async function signup ( username , password ) {
74
70
const data = { username, password } ;
75
71
76
- const res = await fetchURL (
77
- `/api/signup` ,
78
- {
79
- method : "POST" ,
80
- headers : {
81
- "Content-Type" : "application/json" ,
82
- } ,
83
- body : JSON . stringify ( data ) ,
72
+ const res = await fetch ( `${ baseURL } /api/signup` , {
73
+ method : "POST" ,
74
+ headers : {
75
+ "Content-Type" : "application/json" ,
84
76
} ,
85
- false
86
- ) ;
77
+ body : JSON . stringify ( data ) ,
78
+ } ) ;
87
79
88
80
if ( res . status !== 200 ) {
89
81
throw new Error ( res . status ) ;
0 commit comments