Skip to content

Instantly share code, notes, and snippets.

@hpjaj
Last active November 14, 2018 18:01
Show Gist options
  • Save hpjaj/4ccfe11ad04722f070762dbe1731409a to your computer and use it in GitHub Desktop.
Save hpjaj/4ccfe11ad04722f070762dbe1731409a to your computer and use it in GitHub Desktop.
// app/javascript/components/NewPost.js
handleSubmit = event => {
event.preventDefault();
const post = {
title: this.state.title,
body: this.state.body
}
axios
.post('/api/posts', post)
.then(response => {
console.log(response);
console.log(response.data);
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment