I want specific data while making a GET request from the json server but i am getting an error of undefined. Here is the code for get request.
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");
and here is the data in my json server
{
"users": [
{
"id": "1afe2286-3e2b-4113-b155-999d7b289f39",
"email": "zeeshan.naseeb11@gmail.com",
"password": "112"
},
]}
The first argument passed to an onSubmit event handler (which you assign to values) is the event object.
It doesn't have an id (hence undefined appearing in the URL).
You need to get your ID from somewhere it actually exists.