import React from "react"; import { ProductRow } from "./ProductRow"; import { API } from "aws-amplify"; interface FriendsBoughtProps { } interface FriendsBoughtState { isLoading: boolean; recommendations: any[]; // FIXME } export class FriendsBought extends React.Component { constructor(props: FriendsBoughtProps) { super(props); this.state = { isLoading: true, recommendations: [] }; } componentDidMount() { API.get("recommendations", "/recommendations", null) .then(response => { this.setState({ recommendations: response, isLoading: false }); }) .catch(error => alert(error)); } render() { if (this.state.isLoading) return null; return (

Books your friends have bought

{this.state.recommendations.slice(0,5).map(recommendation => )}
); } } export default FriendsBought;