import React from 'react'; import axios from 'axios'; import { Layout } from './shared/Layout'; interface CustomerListItem { customerID: string; name: string; email: string; } function RenderCustomerListItemRows(customers: CustomerListItem[]) { let rows = customers.map(x => { return ( {x.name} {x.email} ); }) return ( {rows} ) } class Customer extends React.Component<{}, {customer: CustomerListItem[] }> { constructor(props) { super(props); this.state = { customer: [], } } async componentDidMount() { try { let data = await axios.get("http://localhost:5000/api/customer");0 console.log(data.data); this.setState({ customer: data.data }); } catch (error) { this.setState({ customer: [], }); } } render() { return ( {RenderCustomerListItemRows(this.state.customer)}
Name Email
); } } export default function CustomerPage() { return ( ) }