‘Oh, it’s like slang, from… England.

fetch('http://url.com/restfulroutes.json')
.then(response => response.json())
.then(data => console.log(data));
function getPoems() {
fetch(baseUrl + '/poems')
.then(function(response) {
return response.json();
})
.then(function(data) {
Poem.createFromCollection(data)
Poem.renderPoems()
})
}
  1. “function getPoems() {“ — declaring our function
  2. “fetch(baseUrl + ‘/poems’)” — our fetch request is being passed an argument. ‘baseUrl’ is a variable declared in our globals file. In our case ‘baseUrl” is set to ‘http://localhost:3000’ (
class Poem {   static createFromCollection(collection) {collection.forEach(data =>
Poem.create(data))
}
static create(attributes) {
let poem = new Poem(attributes);
poem.save();
return poem
}
}
class Poem {   static renderPoems() {
resetMain();
main().innerHTML = Poem.thePoems();
Poem.all.forEach(poem => poem.render());
}
}

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

JAMstack best practices: Adding a serverless back-end to Angular

How To Run VueJS With NodeJS Backend on AWS App Runner

Publishing React Libraries Made Easy

Posts/Deletes on here

Why Node.js is a perfect enterprise app development platform?

Javascript reactivity explained simple

Classifying categorical data in Weka via the API

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Michael Abe

Michael Abe

More from Medium

Que incluye BBB para ti? Free apps for better Hispanic outreach.

Jacob Baranski on Custom Home Building: Foundations and Frameworks

Is WordPress the simplest Platform for Your property Website by Sean Tarpenning

Your Next Road Trip Will Be Narrated