@@ -52,27 +52,27 @@ const Signup = () => {
5252 }
5353
5454 try {
55- // ✅ Avoid unused variable by using "({ confirmPassword, ...payload })"
56- const res = await fetch ( `${ process . env . NEXT_PUBLIC_BACKEND_API } /auth/register` , {
57- method : "POST" ,
58- headers : { "Content-Type" : "application/json" } ,
59- body : JSON . stringify ( ( { confirmPassword, ...payload } = formData , payload ) ) ,
60- } ) ;
55+ const { confirmPassword, ...payload } = formData ; // ✅ Correctly destructure
6156
62- const response = await res . json ( ) ;
57+ const res = await fetch ( `${ process . env . NEXT_PUBLIC_BACKEND_API } /auth/register` , {
58+ method : "POST" ,
59+ headers : { "Content-Type" : "application/json" } ,
60+ body : JSON . stringify ( payload ) , // ✅ Only send needed data
61+ } ) ;
62+
63+ const response = await res . json ( ) ;
6364
64- if ( res . ok ) {
65- toast . success ( response . message , { autoClose : 2000 } ) ;
66- router . push ( "/auth/signin" ) ;
67- } else {
68- toast . error ( response . message , { autoClose : 2000 } ) ;
69- }
70- } catch ( err ) {
71- toast . error ( "Registration failed. Please try again." , { autoClose : 2000 } ) ;
65+ if ( res . ok ) {
66+ toast . success ( response . message , { autoClose : 2000 } ) ;
67+ router . push ( "/auth/signin" ) ;
68+ } else {
69+ toast . error ( response . message , { autoClose : 2000 } ) ;
7270 }
71+ } catch ( err ) {
72+ toast . error ( "Registration failed. Please try again." , { autoClose : 2000 } ) ;
73+ }
7374} ;
7475
75-
7676 return (
7777 < div className = "authout" >
7878 < div className = "authin" >
0 commit comments