forked from VinokurovVE/tests
Auth: SignIn, SignUp (TODO: rewrite into react-hook-form)
This commit is contained in:
@ -1,11 +1,12 @@
|
||||
import { useState, useEffect, useMemo } from 'react';
|
||||
import axiosInstance from '../http/axiosInstance';
|
||||
export function useDataFetching<T>(url: string, initData: T): T {
|
||||
const [data, setData] = useState<T>(initData);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
const response = await fetch(url);
|
||||
const result = await response.json();
|
||||
const response = await axiosInstance.get(url);
|
||||
const result = await response.data;
|
||||
setData(result);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user