score:2
Accepted answer
To get rid of the javascript.map
is 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.
Source: stackoverflow.com
Related Query
- SQL search and JavaScript .map is not a function
- Using Async/Await with Fetch in a JavaScript map function not executing in order
- Map function not working while passing props into React component (TypeScript, React and Next.js)
- JavaScript Map Function with React.js gives me index, but not value in the index
- How Use images from javascript array in react using filter and map function
- Javascript multi dimensional map and reduce function
- map function in javascript not working properly for React components
- React push object into array and map error map not a function
- Javascript Map Function Not Storing Correct Value
- Function is not defined, but it is defined. React and Javascript
- Expected an assignment or function call and instead saw an expression error in react if return is not present inside map statement why?
- React search and filter: TypeError: setFilterFn is not a function
- Changes do not affevt on the map function and do not show :)
- "this.props" not working in my on mouseup event function in Map Component using react and mapbox-gl
- Slice and Map an array in Javascript but not seeing sliced array appear
- Attempting to learn React and Javascript but stuck on this strange syntax for map and passing an anonymous function to it
- How can I use Map function for an Array with values and another array as a value in Javascript
- ReactJS: React.render is not a function and React.createElement is not a function
- How to fix nextCreate is not a function setting up useMemo setting up authentication react router and hooks
- What's the difference between a JavaScript function and a React hook?
- Function lacks ending return statement and return type does not include 'undefined'
- For a React app, can the build process not create a JavaScript map file?
- map function not working in React
- Why mapStateToProps and mapDispatchToProps are not just one function in Redux?
- When using ES6, how can an imported function be undefined in one file, and not in another?
- Object.fromEntries is not a function error when using chakra-ui and next.js
- how to access vairables outside of map function in js and jsx in a React component
- React JS : history.push is not a function error and it isn't navigating to a different page onclick of swal
- React.js and ES6: Any reason not to bind a function in the constructor
- TypeError: Object(...) is not a function with React Table and moment.js
More Query from same tag
- Get default message for required validation
- Redux action must be plain objects
- React useState in context does not update
- Why we use (null) while creating dropdown in react js?
- Difference between passing in null and undefined in useRef
- Change values of an object
- Passing a Redux Action to a child component with props
- React app failed to load resource: the server responded with a status of 404 GraphQL
- React functional component: clearInterval() does not clear my interval
- How can i pass a state from one react route to another react route?
- Lazy-loading React components under SSR
- inline CSS style is not getting rendered [Previously: Component is not rendering its elements - react]
- Accessing return variable of React class component
- React: How to render a list of items grouped by category (using .map)
- How to add html elements to a string and display them?
- Filtering data using react hooks
- redux hook fetch data from API with action in separate file
- React Google Identity services
- ant design progress bar. Using steps prevents full width
- Redux : reset 1 variable to initial state in Redux
- React Konva, blueimp-load-image uploaded Image rescaling
- Redux dispatch action not firing
- How do you render div objects from non-React libraries in React?
- How to prevent Visual Studio node command prompt from closing on exit?
- Warning: Each child in a list should have a unique “key” prop
- getBoundingClientRect returning same value in Chrome
- How to access an error object (sent from the backend) properly from an action creator?
- Make properly schema and resolver for update a table in GraphQL Apollo
- Unable to pass access_token to endpoint in Reactjs
- React & firebase- uncaught TypeError: Cannot read property 'setState' of undefined