import React from 'react'; import API from '../../lib/API'; import {Link} from 'react-router-dom'; class AnswerKeyList extends React.Component { constructor(props) { super(props); this.api = new API(); this.state = { courses: new Array(0), }; this.api.answerKeys.list().then(r => this.setState({courses: r.courses})); } getCreatedAt(unixEpoch) { if (!unixEpoch) { return ''; } const date = new Date(); date.setTime(unixEpoch); return date.getMonth() + '/' + date.getDate() + '/' + date.getFullYear(); } render() { const courseRows = this.state.courses.map((course, index) => ( {course.name} {this.getCreatedAt(course.created_at)} edit )); return (

Answer Keys

{courseRows}
Course name Created  
); } } export default AnswerKeyList;