feat(useApi): better interface
This commit is contained in:
12
app/types/query-result.ts
Normal file
12
app/types/query-result.ts
Normal 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>;
|
||||
}
|
||||
Reference in New Issue
Block a user