scrimba
Frontend Career Path
Working with APIs
URLs & REST
BlogSpace - Form submit event listener
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

BlogSpace - Form submit event listener
AboutCommentsNotes
BlogSpace - Form submit event listener
Expand for more info
index.js
run
preview
console
fetch("https://apis.scrimba.com/jsonplaceholder/posts")
.then(res => res.json())
.then(data => {
const postsArr = data.slice(0, 5)
let html = ""
for (let post of postsArr) {
html += `
<h3>${post.title}</h3>
<p>${post.body}</p>
<hr />
`
}
document.getElementById("blog-list").innerHTML = html
})

/**
Challenge:

* Listen for the "submit" event on the form (which will happen when the button is clicked)
* (Don't forget to preventDefault on the form so it doesn't refresh your page. Google "form preventDefault" if you're not sure what I'm talking about)
* Combine the title value and body value into an object (with a "title" property and "body" property)
* Log the object to the console

*/
Console
/index.html
-3:37