fixed network config and wrong paths in frontend
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { fetch } from '@tauri-apps/plugin-http';
|
||||
import { initAuth, logout } from '../store.ts'
|
||||
import { API } from '../main.ts'
|
||||
import router from '../router'
|
||||
@@ -9,6 +10,8 @@ export async function apiFetch<T>(
|
||||
const auth = await initAuth()
|
||||
|
||||
const res = await fetch(`${API}${path}`, {
|
||||
method: options.method || 'GET',
|
||||
body: options.body,
|
||||
...options,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -28,5 +31,5 @@ export async function apiFetch<T>(
|
||||
throw new Error(text || res.statusText)
|
||||
}
|
||||
|
||||
return res.json()
|
||||
return res.json() as Promise<T>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { apiFetch } from './client'
|
||||
import type { Friend, FriendRequest } from '../api'
|
||||
import type { Friend, FriendRequest } from '../types'
|
||||
|
||||
export function fetchFriends() {
|
||||
return apiFetch<Friend[]>('/friends')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { apiFetch } from './client'
|
||||
import type { Message } from '../api'
|
||||
import type { Message } from '../types'
|
||||
|
||||
export function fetchMessages(roomUuid: string) {
|
||||
return apiFetch<Message[]>(`/messages/${roomUuid}`)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { apiFetch } from './client'
|
||||
import type { Room } from '../api'
|
||||
import type { Room } from '../types'
|
||||
|
||||
export function fetchRooms(userUuid: string) {
|
||||
return apiFetch<Room[]>(`/rooms/${userUuid}`)
|
||||
|
||||
Reference in New Issue
Block a user