Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleCommentSubmit(comment) {
this.setState({ isSaving: true });
const requestConfig = {
responseType: 'json',
headers: ReactOnRails.authenticityHeaders(),
};
return (
request
.post('comments.json', { comment }, requestConfig)
.then(() => {
const { $$comments } = this.state;
const $$comment = Immutable.fromJS(comment);
this.setState({
$$comments: $$comments.unshift($$comment),
submitCommentError: null,
isSaving: false,
});
})
.catch(error => {
submitEntity(entity) {
return request({
method: 'POST',
url: API_URL,
responseType: 'json',
headers: ReactOnRails.authenticityHeaders(),
data: entity,
});
},