score:2

Accepted answer

To get rid of the javascript.mapis not a function error in your react code you have to replace tbody in your react code in the following way to handle your empty restaurants array until its state gets updated from the HTTP response.

<tbody>
{
    restaurants.length > 0 && restaurants.map((restaurants) => (
    <tr key={restaurants.restaurants_id}>
        <td>{restaurants.name}</td>
        <td>{restaurants.location}</td>
    </tr>
    ))
}
</tbody>

Your another question related to not getting response from the backend for your postgre SQL query, you must console.log() your query and try running it on SQL interface to find the syntactical errors.


Related Query

More Query from same tag