Created
October 5, 2018 13:53
-
-
Save jacopocolo/41aa1b2f5103bfb7bc92f39b1b70fb64 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
import * as React from "react"; | |
import Avatar from "@collab-ui/react/lib/Avatar"; | |
import "@collab-ui/core/css/collab-ui.min.css"; | |
import "@collab-ui/icons/css/collab-ui-icons.css"; | |
import { PropertyControls, ControlType, Data } from "framer"; | |
const style: React.CSSProperties = { | |
margin: "0 0 20px 20px", | |
objectFit: "cover" | |
}; | |
export class Avatar extends React.Component { | |
state = { | |
astronauts: [], | |
avatars: [] | |
} | |
// Fetch Astronauts | |
fetchAstronauts() { | |
fetch("http://api.open-notify.org/astros.json") | |
.then(data=>{return data.json()}) | |
.then(astronautsResult=>{ | |
fetch("https://tinyfac.es/api/users") | |
.then(data=>{return data.json()}) | |
.then(avatarResults=>{ | |
this.setState({ | |
astronauts: astronautsResult.people, | |
avatars: avatarResults | |
}); | |
}) | |
}) | |
} | |
componentDidMount(){ | |
this.fetchAstronauts(); | |
//this.fetchAvatars(); | |
}; | |
render() { | |
return ( | |
<div> | |
{ | |
this.state.astronauts.map((element, i) => { | |
return <Avatar style={style} src={this.state.avatars[i].avatars[1].url} size={80} title={element.name}/> | |
}) | |
} | |
</div> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment