Hello,
I am facing a problem in mern stack. I cannot make a crud application. i have done redux here too.
i can add item, but that item is not showing actually.
in add item i did this in action in redux
export const addItem = (item) => dispatch =>{
axios.post('/api/profile/add',item)
.then(res=>dispatch({
type:ADD_ITEM,
payload:res.data
}))
}
in fetching item i used.
export const getItems = () => dispatch =>{
dispatch(setItemsLoading());
axios.get('/api/profile')
.then(res=>dispatch({
type:GET_ITEMS,
payload:res.data
}
in item list where items will be seen react js
{items.map(({_id,item})=>
(
<div key={_id}>
<h2>{item}</h2>
<button className="btn btn-success btn-sm" onClick={this.onDeleteClick.bind(this, _id)}>Delete</button>
</div>
)
)}
please help me how to fix it.