I am encountering an issue while utilizing the next.js app directory and attempting to make a POST request using axios.
const submitHandler = async (e) => {
e.preventDefault();
try {
const {data} = await axios.post('/api/register', {
name,
email,
password,
});
console.log(data);
} catch (error) {
console.log(error);
}
};
The error message (excerpt):
error - Error [TypeError]: Cannot read properties of undefined (reading 'prototype')
at eval (webpack-internal:///(sc_server)/./node_modules/mongoose/lib/types/objectid.js:15:36)
at (sc_server)/./node_modules/mongoose/lib/types/objectid.js (/Users/yakovtzur/Documents/Coding/Development/next_13_authjs/.next/server/app/api/register/route.js:2870:1)
at __webpack_require__ (/Users/yakovtzur/Documents/Coding/Development/next_13_authjs/.next/server/webpack-runtime.js:33:43)
at eval (webpack-internal:///(sc_server)/./node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:7:18)