Skip to content

Commit 84e7db1

Browse files
committed
fixed load error
1 parent a0b7f3b commit 84e7db1

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

componets/add.jsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,17 @@ async function deleteItem(idx) {
115115
const req = await fetch(`${url}/api/todo/`, { credentials: 'include' })
116116

117117

118+
119+
120+
if(req.status ==200){
118121
const res = await req.json();
119-
console.log(res)
120122

121123
setData({ todos: res.data })
122124

125+
}else {
123126

127+
router.replace("/login")
128+
}
124129

125130
}
126131

pages/login.jsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,19 @@ const Login = function () {
101101
let res = await req.json()
102102
router.replace('/todo');
103103

104-
console.log(res);
104+
// console.log(res);
105105
}
106+
else if(req.status ==400){
106107

108+
alert("Invalid username or password")
107109

108-
else {
109110

110-
alert("Something went wrong from server")
111111
}
112+
else {
113+
alert("Something went wrong! Error:", req.status )
114+
}
115+
116+
112117

113118

114119
}

0 commit comments

Comments
 (0)