Any way to use the use the same use fetch and be able to tell apart call's responses? Here is an example, for the most part it looks like it would work, but how could the methods loadData1 and loadData2 be able to tell if response.ok is from which api call?
import useFetch from 'use-http'
function Todos() {
const [path1Data, setPath1Data] = useState([])
const [path2Data, setPathData] = useState([])
const { get, response } = useFetch('')
const loadData1 = async () => {
const data1 = await get('/path1')
if (response.ok) setPath1Data(data1)
}
const loadData2 = async () => {
const data2 = await get('/path2')
if (response.ok) setPath2Data(data2)
}
// componentDidMount
useEffect(() => {
loadData1()
loadData2()
}, [])
Thank you
Any way to use the use the same use fetch and be able to tell apart call's responses? Here is an example, for the most part it looks like it would work, but how could the methods
loadData1andloadData2be able to tell ifresponse.okis from which api call?Thank you