mirror of
https://github.com/BarkProductions/barkman.git
synced 2026-08-11 11:42:03 +00:00
list hook
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import {useQuery} from "@tanstack/react-query";
|
||||
import {Job} from "../types.ts";
|
||||
|
||||
const useJobList = () => useQuery({
|
||||
queryKey: ['job'],
|
||||
queryFn: async (): Promise<Job[]> => {
|
||||
const response = await fetch(
|
||||
import.meta.env.VITE_API_URL + '/jobs',
|
||||
)
|
||||
|
||||
if (!response.ok) throw new Error('Failed to fetch jobs ' + response.statusText)
|
||||
|
||||
return await response.json()
|
||||
},
|
||||
});
|
||||
|
||||
export default useJobList;
|
||||
Reference in New Issue
Block a user