After updating my dependencies, I encountered an issue every time I clicked on a button to navigate to the next page. The error message
Uncaught (in promise) TypeError: Cannot read properties of null (reading 'parentNode')
would appear, even though the router was not null when logged. Interestingly, upon refreshing the page, the router successfully navigated me to the next page.
The problematic code snippet is as follows:
const router = useRouter();
return await api
.getByPostalCode(params)
.then((response: PostalCodeResult) => {
result.value = response;
router.push({ path: getBaseRoute('next-route') });
})
.catch((error) => {
return Promise.reject(error);
});
}
Removing the router.push
part also eliminates the error. Reviewing the flow confirms that I reach the then
block without any issues.
Here are the versions of dependencies I am currently using:
"vitest": "^1.0.4",
"nuxt": "^3.9.1",
"nuxt-vite": "^0.3.5",
"@pinia/nuxt": "^0.5.1",
If there are specific versions required for other dependencies, kindly let me know.