I have a project setup in node, express as backend and react as frontend, In node i have written
JSON.stringify(`${some_value}`);
and it is saved in the database.
To fetch, I am using useEffect hook and axios.get to the records from the database and rendered in the jsx
Is the above method the an good practice ???
const [allProjects, setAllProjects] = useState([]);
useEffect(() => {
... Axios.get ... other code
setAllProjects(result); // if successfull response store it in state
In the return I have the below code
return (
... other code
{allProjects.map((value) => {
... other codes
allProjects.responsibilites.map((value) => {
return(
<p>{value.role}</p>
)
})}
allProjects.responsibilities has
[{"role":"manager","name":"Test"},{"role":"manager","name":"Test 2"}]
I am getting TypeError: Cannot read property 'map' of undefined