fix api path
This commit is contained in:
+6
-3
@@ -1,5 +1,7 @@
|
||||
import type { GraphResponse, Positions } from './types'
|
||||
|
||||
const API_BASE = `${import.meta.env.BASE_URL}api`
|
||||
|
||||
export class ApiError extends Error {
|
||||
constructor(message: string, public status: number) {
|
||||
super(message)
|
||||
@@ -27,13 +29,14 @@ async function request<T>(url: string, init?: RequestInit): Promise<T> {
|
||||
}
|
||||
|
||||
export const getGraph = (refresh = false) =>
|
||||
request<GraphResponse>(`/api/graph${refresh ? '?refresh=1' : ''}`)
|
||||
request<GraphResponse>(`${API_BASE}/graph${refresh ? '?refresh=1' : ''}`)
|
||||
|
||||
export const savePositions = (key: string, positions: Positions) =>
|
||||
request<{ saved: number }>(`/api/positions/${key}`, {
|
||||
request<{ saved: number }>(`${API_BASE}/positions/${key}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ positions }),
|
||||
})
|
||||
|
||||
export const resetPositions = (key: string) => request<void>(`/api/positions/${key}`, { method: 'DELETE' })
|
||||
export const resetPositions = (key: string) =>
|
||||
request<void>(`${API_BASE}/positions/${key}`, { method: 'DELETE' })
|
||||
Reference in New Issue
Block a user