【发布时间】:2021-12-06 01:36:15
【问题描述】:
当我尝试记录时,我的控制台中有数据,但我无法使用它。
我的数据对象看起来像:
{_id:'616bf82d16a2951e53f10da4',姓名:'abd',电子邮件:'q@gmail.com',电话:'1234567890',工作:'singer',……}
访问令牌:“eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYxNmJmODJkMTZhMjk1MWU1M2YxMGRhNCImlhdCI6MTYzNDYyMDk3MiwiZXhwIjoxNjM1MDUyOTcyfQ.b9NZB-ogrdu_SulT1xJ8h62j”
cpassword: "$2a$12$BZ17rY63qrq.Fw9wC29A.eabcuAHSY0mXfxSvcpxOFGfUeW4NUkMO"
电子邮件:“q@gmail.com”
名称:“abd”
电话:“1234567890”
代币:(3) [{…}, {…}, {…}]
作品:“歌手”
__v: 3
_id:“616bf82d16a2951e53f10da4”
[[原型]]:对象
import "./about.css"
import {useHistory} from "react-router-dom"
export default function About() {
const history=useHistory();
const [userData,setUserData]=useState();
const callAboutPage=async()=>{
try {
const res=await fetch("/about",{
method:"GET",
headers:{
Accept:"application/json",
"Content-Type":"application/json"
},
credentials:"include"
})
const data=await res.json();
console.log(data);
setUserData(data);
if(!res.status===200){
const error=new Error (res.error)
throw error
}
} catch (error) {
console.log(error)
history.push("/login")
}
}
useEffect(() => {
callAboutPage();
}, [])
return (
<div className="abt-body">
<div className=" d-flex justify-content-center align-items-center about">
Name:{userData.name}
<br />
Id:{userData._id}
<br />
Email:{userData.email}
<br />
Phone:{userData.phone}
<br />
Work:{userData.work}
</div>
<div class="card-footer text-muted d-flex justify-content-center align-items-center">
Designed and Developed by : Harsh Raj Ambastha
</div>
</div>
)
}
【问题讨论】:
-
在一个可以被数千人阅读的问题中包含个人信息是不好的。
标签: javascript reactjs