next-enterprise/datafetch/datafetch.js

34 lines
713 B
JavaScript
Raw Normal View History

2024-02-29 09:33:34 +01:00
import useSWR from "swr"
const fetcher = (...args) => fetch(...args).then((res) => res.json())
export function menuitemfetcher(url) {
2024-03-13 20:16:29 +01:00
const { data, error, isLoading } = useSWR("http://192.168.178.20:3001/data", fetcher)
2024-02-29 09:33:34 +01:00
return {
data: data,
isLoading,
isError: error,
}
}
export function learningitemfetcher(url) {
const { data, error, isLoading } = useSWR("https://jsonplaceholder.typicode.com/posts", fetcher)
return {
data: data,
isLoading,
isError: error,
}
}
export function learningpodfetcher() {
const { data, error, isLoading } = useSWR("https://jsonplaceholder.typicode.com/posts", fetcher)
return {
data: data,
isLoading,
isError: error,
}
}