Created
July 3, 2019 16:55
-
-
Save jaredlockhart/763e24ee2c699f7626dd590fd78cc2a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getPeople(callback) { | |
$.get("people", callback); | |
} | |
function getPerson(id, callback) { | |
$.get("person/{id}", callback); | |
} | |
function storePerson(data, callback) { | |
db.call("INSERT INTO PEOPLE VALUES {data}", callback); | |
} | |
getPeople(function(people) { | |
for(person in people) { | |
getPerson(person["id"], function (personData) { | |
storePerson(personData, function (dbOK) { | |
console.log("person stored"); | |
} | |
} | |
} | |
}) | |
function getPeople() { | |
return fetch("people"); | |
} | |
function getPerson(id) { | |
return fetch("person/{id}"); | |
} | |
function storePerson(data) { | |
return db.call("INSERT INTO PEOPLE VALUES {data}"); | |
} | |
getPeople().then(people => { | |
for (person in people) { | |
getPerson(person["id"]).then(data => { | |
storePerson(data).then(dbOK => { | |
console.log("person stored"); | |
}); | |
}) | |
} | |
}) | |
let people = await getPeople(); | |
for (person in people) { | |
let data = await getPerson(person["id"]); | |
let dbOK = await storePerson(data); | |
console.log("person stored"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment