Im following a tutorial seems to be on a older version of Next.js this seems to work prior but now its throwing an error.
error is not defined
This is the code
export default function DeleteIcon({ id }) {
const [isLoading, setIsLoading] = useState(false)
const router = useRouter()
const handleClick = async () => {
setIsLoading(true)
const res = await fetch(`http://localhost:3000/api/tickets/${id}`, {
method: 'DELETE'
})
const json = await res.json()
if (json.error) {
console.log(error)
setIsLoading(false)
}
if (!json.error) {
router.refresh()
router.push('/tickets')
}
}
What is the best way to resolve this issue or best practice.