you try this way
const fetchBusinesses = () => {
return fetch("theURL", {method: "GET"}
)
.then(res => normalizeResponseErrors(res))
.then(res => {
return res.json();
})
.then(rcvdBusinesses => {
// some stuff
})
.catch(err => {
// some error handling
});
};
and
useEffect(() => {
fetchBusinesses();
});
it's work for you. But my suggestion is try this way also work for you. It's better than before way. I use this way:
useEffect(() => {
const fetchBusinesses = () => {
return fetch("theURL", {method: "GET"}
)
.then(res => normalizeResponseErrors(res))
.then(res => {
return res.json();
})
.then(rcvdBusinesses => {
// some stuff
})
.catch(err => {
// some error handling
});
};
fetchBusinesses();
}, []);
if you get data on the base of specific id then add in callback useEffect [id]
then cannot show you warning
React Hook useEffect has a missing dependency: 'any thing'. Either include it or remove the dependency array