Created
September 4, 2019 17:49
-
-
Save trycf/97ab3e05776d130cf142cdbe973c746e to your computer and use it in GitHub Desktop.
TryCF Gist
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
<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