Having issues updating session in NextAuth
Unanswered
Sokoke posted this in #help-forum
SokokeOP
So i want to update my session user name so that i can get it from the server side and update the db along wiht uploading a picture. I'm attaching the file but here's the part of the code where I'm trying to update it
async function onSubmit(
values: z.infer<typeof usernameSchema> & { imageUrl?: string },
) {
setMessage(null);
await update({
...session,
user: {
...session?.user,
name: values.name,
},
});
console.log(session);
try {
if (imageFile) {
setIsUploading(true);
await startUpload([imageFile]);
} else {
console.log("Form submitted");
}
} catch (error) {
console.error("Submission error:", error);
setMessage("Error occurred during submission.");
} finally {
setIsUploading(false);
}
}