Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trycf/97ab3e05776d130cf142cdbe973c746e to your computer and use it in GitHub Desktop.
Save trycf/97ab3e05776d130cf142cdbe973c746e to your computer and use it in GitHub Desktop.
TryCF Gist
<cfscript>
starWarsPeeps = getPeople();
//writeDump( starWarsPeeps );
writeDump(
starWarsPeeps.filter(
(person)=>person.name == "R2-D2")[1]
.getHomeWorld()
);
function getPeople( uri = "https://swapi.co/api/people/"){
var people = get(uri);
people.results.map((person)=>{
person["getHomeWorld"] = ()=>get( person.homeworld );
});
return people.results;
}
function get(uri){
cfhttp(url=uri, method="GET", result="response");
return deserializeJSON( response.fileContent );
}
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment