I am running some trouble with this function when I apply the useEffect
hook. Does Anyone know how could I solve this?
const [expenses, setExpenses] = UseState([])
const getItems = async() => {
try {
// Right now we are receiving all the expenses and filtering by the username but we should only receive the one from the username --> that will be modified
const data = await axios.get('https://controladorgastosapi.herokuapp.com/expenses/', {
headers: {
username: user.userInfo.username
}
})
const result = data.data
setExpenses(result)
} catch (err) {
console.log(err)
}
}
useEffect(() => {
getItems()
}, [expenses])