Skip to content

Instantly share code, notes, and snippets.

@jacopocolo
Created October 5, 2018 13:53
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 jacopocolo/41aa1b2f5103bfb7bc92f39b1b70fb64 to your computer and use it in GitHub Desktop.
Save jacopocolo/41aa1b2f5103bfb7bc92f39b1b70fb64 to your computer and use it in GitHub Desktop.
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