Skip to content
Advertisement

How to retrieve data from a Firestore database

I am doing a project in React, where after I type a value and then click on search button, the app searches if the id exists in the database. If so, it displays the result of the search in the same page. I am having trouble assigning the value of the search and then displaying it. When I try to assign the result of the search to an array, it gives me the error:

JavaScript

When I did a console.log of just the data in no variable, I can get the results, but I need it in the setId variable.

Here is the code:

JavaScript

Advertisement

Answer

After long days I found the solution: I traded this:

JavaScript

to:

JavaScript
Advertisement