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