我在Reaction是新手,因为我正在构建TODO应用程序,我在代码中面临的错误很少,因为我的代码运行不正常,我还想添加一个功能,就像在API中发生任何错误一样,我能够在我的前端显示它.
在解决了所有这些问题之后,我想知道导航是如何工作的,因为我想导航到Create-Todo路由.
我在Reaction是新手,因为我正在构建TODO应用程序,我在代码中面临的错误很少,因为我的代码运行不正常,我还想添加一个功能,就像在API中发生任何错误一样,我能够在我的前端显示它.
在解决了所有这些问题之后,我想知道导航是如何工作的,因为我想导航到Create-Todo路由.
import React, { useState } from 'react'
import { useNavigate } from 'react-router-dom';
export default function LoginPage() {
const[username , setUsernamne] = useState("");
const[password , setPassword] = useState("");
const navigate = useNavigate();
return (
<div>
.
.
.
</div>
<div style={{ paddingTop: "18px", paddingLeft: "10px", }}>
<button onClick={async ()=>
{ await fetch("http://localhost:3005/signin",{ method: "POST", body: JSON({
username: username, password: password }), headers:{ "content-type": "application/json",
} }).then(async function(res){ const json = await res.json(); console.log(json);
}) }} >Login
</button>
</div>
)
}