i'm trying to create delete button that delete a group of objects instead of one object, but the axios request don't work inside the forEach loop.
function handleClick(e) {
cont GetByName = axios.get('my/api/link').filter(i => i.mylist === `${name}`)
GetByName.forEach(i => axios.delete('my/api/link'+i.id))
}
Please Note: I didn't add .then(res=>consolse.log(res)
just to make it make it brief.
Also note: that using console.log
instead of axios.delete
is working very fine.
Maybe I can explain my problem in another approach
const [Id,setId] = useState(null)
function handleClick(e) {
cont GetByName = axios.get('my/api/link').filter(i => i.mylist === `${name}`)
GetByName.forEach(i => setId(i.id))
console.log(Id)
}
this console.log
return null