【发布时间】:2023-04-11 03:56:01
【问题描述】:
我在从 json 服务器发出 GET 请求时需要特定数据,但我收到未定义的错误。这是获取请求的代码。
onSubmit={(values) => {
axios
.get(`http://localhost:3001/users/${values.id}`)
.then((resp) => {
if (values.email === resp.data.email) {
console.log(resp.data);
} else console.log("usereename or pass invalid");
这是我的 json 服务器中的数据
{
"users": [
{
"id": "1afe2286-3e2b-4113-b155-999d7b289f39",
"email": "zeeshan.naseeb11@gmail.com",
"password": "112"
},
]}
【问题讨论】:
标签: javascript reactjs rest react-redux json-server