feat(useApi): better interface

This commit is contained in:
2025-11-19 22:03:35 +01:00
parent 355653e4f2
commit 0b65e17903
11 changed files with 1080 additions and 106 deletions

19
app/types/http-method.ts Normal file
View File

@@ -0,0 +1,19 @@
export type HttpMethod =
| 'delete'
| 'get'
| 'GET'
| 'HEAD'
| 'PATCH'
| 'POST'
| 'PUT'
| 'DELETE'
| 'CONNECT'
| 'OPTIONS'
| 'TRACE'
| 'head'
| 'patch'
| 'post'
| 'put'
| 'connect'
| 'options'
| 'trace';

12
app/types/query-result.ts Normal file
View File

@@ -0,0 +1,12 @@
import type { ApiError } from './api/error';
export class QueryResult<T, PayloadT> {
/** Reactive data - `null` until the request succeeds */
data: Ref<T | null> = ref(null);
/** Reactive error - `null` until an error occurs */
error: Ref<ApiError | null> = ref(null);
/** Whether the request is currently in flight */
loading: Ref<boolean> = ref(false);
/** Runs the query - Will be filled by the request helper */
run!: (requestBody?: PayloadT) => Promise<void>;
}