Add a form

Next, let's add a form to the page and get ready to handle it.

<script src="[email protected]/dist/index.js"></script>
<input type="text" name="title">
<textarea name="content" cols="80" rows="10"></textarea>
<button type="submit">Submit</button>
// Listen for the form submit event. We will use an ajax
// request to send the new article to the API.
var form = document.getElementsByTagName('form')[0];
form.addEventListener('submit', function(e) {
var body = {
title: form.elements['title'].value,
content: form.elements['content'].value

Open the index.html in your browser and open the debug console. Fill out and submit the form. You'll see a bunch of JSON output. Something like:

"title": "This is a title",
"content": "This is the content."