-
-
Save StephenDRoberts/9d2596578fa92bebd1a2d8d62c88cbd7 to your computer and use it in GitHub Desktop.
Query hook to fetch data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect } from 'react'; | |
import { DailyPrice, APIResponse } from '../types/types'; | |
import { get } from '../fetchers/fetchers'; | |
export const useGetDailyPrices = () => { | |
const [data, setData] = useState<DailyPrice[]>([]); | |
const getData = async () => { | |
const { results } = await get<APIResponse>('./data/DUMMY_DATA.json'); | |
setData(results) | |
} | |
useEffect(() => { | |
getData() | |
}, []) | |
return data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment