|
|
|
|
@ -21,7 +21,21 @@ class CommentsForm extends React.Component {
|
|
|
|
|
const mapDispatchToProps = function(dispatch){
|
|
|
|
|
return {
|
|
|
|
|
handleSubmit: function(body){
|
|
|
|
|
fetch(
|
|
|
|
|
'http://localhost:3000/comments',
|
|
|
|
|
{
|
|
|
|
|
headers: {
|
|
|
|
|
'Accept': 'application/json',
|
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
|
},
|
|
|
|
|
method: "POST",
|
|
|
|
|
body: JSON.stringify({ body:body })
|
|
|
|
|
}
|
|
|
|
|
).then(function(response){
|
|
|
|
|
response.json().then(function(data){
|
|
|
|
|
dispatch({type:'ADD', comment: { body: body }});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|