DEV Community

Discussion on: How To Write a Search Component with Suggestions in React

Collapse
 
abhi4pr profile image
abhi4pr

Sir i got an error (Unhandled Rejection (TypeError): Cannot read property 'data' of undefined).
in this line (results:data.data).

I created my own API.

app.get('/Search',function(req,res){
con.query("select * from webtable where username like '%username%'",
function(err,searchrs){
console.log("Search results:",searchrs);
res.json(searchrs);
})
});

What corrections this API need ?
How to resolve that above error ?

Please answer me soon
Thanks in advance.

Collapse
 
xocedev profile image
antonio.nicasio.herrera@gmail.com

out need to check your output response because data is not declared the error says all
Cannot read property 'data' of undefined