File tree 2 files changed +14
-4
lines changed
2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -115,12 +115,17 @@ async function deleteItem(idx) {
115
115
const req = await fetch ( `${ url } /api/todo/` , { credentials : 'include' } )
116
116
117
117
118
+
119
+
120
+ if ( req . status == 200 ) {
118
121
const res = await req . json ( ) ;
119
- console . log ( res )
120
122
121
123
setData ( { todos : res . data } )
122
124
125
+ } else {
123
126
127
+ router . replace ( "/login" )
128
+ }
124
129
125
130
}
126
131
Original file line number Diff line number Diff line change @@ -101,14 +101,19 @@ const Login = function () {
101
101
let res = await req . json ( )
102
102
router . replace ( '/todo' ) ;
103
103
104
- console . log ( res ) ;
104
+ // console.log(res);
105
105
}
106
+ else if ( req . status == 400 ) {
106
107
108
+ alert ( "Invalid username or password" )
107
109
108
- else {
109
110
110
- alert ( "Something went wrong from server" )
111
111
}
112
+ else {
113
+ alert ( "Something went wrong! Error:" , req . status )
114
+ }
115
+
116
+
112
117
113
118
114
119
}
You can’t perform that action at this time.
0 commit comments