init
This commit is contained in:
@@ -5,7 +5,6 @@ function authHeaders() { return { 'Authorization': `Bearer ${token()}`, 'Content
|
||||
|
||||
export interface SmsMessage {
|
||||
id: number;
|
||||
user_id: number;
|
||||
phone_number: string;
|
||||
contact_name: string | null;
|
||||
content: string;
|
||||
@@ -31,21 +30,11 @@ async function parseError(res: Response): Promise<string> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function login(username: string, password: string) {
|
||||
const res = await fetch(`${BASE}/auth/login`, {
|
||||
export async function verifyToken(t: string) {
|
||||
const res = await fetch(`${BASE}/auth/verify`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json; charset=utf-8' },
|
||||
body: JSON.stringify({ username, password }),
|
||||
});
|
||||
if (!res.ok) throw new Error(await parseError(res));
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function register(username: string, password: string) {
|
||||
const res = await fetch(`${BASE}/auth/register`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json; charset=utf-8' },
|
||||
body: JSON.stringify({ username, password }),
|
||||
body: JSON.stringify({ token: t }),
|
||||
});
|
||||
if (!res.ok) throw new Error(await parseError(res));
|
||||
return res.json();
|
||||
|
||||
Reference in New Issue
Block a user