forked from Ada-C11/video-store-consumer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added customer and customerlist components
- Loading branch information
Showing
3 changed files
with
72 additions
and
5 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const Customer = (props) => { | ||
return ( | ||
<div> | ||
<Customer/> | ||
</div> | ||
) | ||
|
||
|
||
|
||
|
||
} | ||
export default Customer; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { Component } from 'react'; | ||
import { BrowserRouter as Router, Route, Link } from "react-router-dom"; | ||
import axios from 'axios'; | ||
import Customer from './Customer' | ||
|
||
class CustomerList extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
customerList: [], | ||
} | ||
} | ||
|
||
|
||
componentDidMount() { | ||
axios.get('http://localhost:3000/customers') | ||
.then((response) => { | ||
console.log(response.data); | ||
this.setState( [{customerList: response.data}]) | ||
// const customers = response.data.map(customer => { | ||
// return <li> | ||
// Name: {customer.name} | ||
// </li> | ||
// }); | ||
|
||
// this.setState( {customerList: customers}) | ||
}) | ||
.catch((error) => { | ||
this.setState({ | ||
errorMessage: error.message | ||
}) | ||
}) | ||
|
||
} | ||
|
||
render() { | ||
return ( | ||
<div>{this.state.customerList}</div> | ||
) | ||
} | ||
|
||
|
||
} | ||
|
||
export default CustomerList; | ||
|
||
|