mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-06-06 18:31:00 +00:00
Create file src/hooks/useCourses.js
This commit is contained in:
parent
a12783270f
commit
83d847ab0c
14
src/hooks/useCourses.js
Normal file
14
src/hooks/useCourses.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { useQuery } from '@tanstack/react-query';
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
|
const fetchCourses = async () => {
|
||||||
|
const { data } = await axios.get('/api/courses');
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useCourses = () => {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ['courses'],
|
||||||
|
queryFn: fetchCourses,
|
||||||
|
});
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user