Next.js Discord

Discord Forum

TypeError: destroy is not a function. (In 'destroy()', 'destroy' is an instance of Promise)

Unanswered
Burmese posted this in #help-forum
Open in Discord
BurmeseOP
Getting this error probably due to useEffect i guess.
Any reason or solution would be appreciated.

1 Reply

Staffordshire Bull Terrier
try something like this. use .then in fetch instead of wait. useEffect(() => {
fetch('https://api.example.com/data')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
setData(data);
})
.catch(error => {
setError(error);
});
}, []);