for some reason this doesn't work when trying to parse the return json body object
const validateUsername = () => {
fetch("/api/user/validate", {
method: "POST",
body: JSON.stringify({
validating: "username",
username: registerUsername
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(err => console.error(err.statusText))
}
gives this error: - error TypeError: Cannot read properties of undefined (reading 'headers') at eval (webpack-internal:///(sc_server)/./node_modules/next/dist/server/future/route-modules/app-route/module.js:277:61)