Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 9 additions & 27 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**

Code in this file is taken directly from https://reactrouter.com/web/example/basic
*/

import React from "react";
import {
BrowserRouter as Router,
Expand All @@ -11,6 +6,9 @@ import {
Link
} from "react-router-dom";

import Products from './Products'
import Logos from './Logos'

// This site has 3 pages, all of which are rendered
// dynamically in the browser (not server rendered).
//
Expand All @@ -29,10 +27,10 @@ export default function BasicExample() {
<Link to="/">Home</Link>
</li>
<li>
<Link to="/about">About</Link>
<Link to="/products">Products</Link>
</li>
<li>
<Link to="/dashboard">Dashboard</Link>
<Link to="/logos">Logos</Link>
</li>
</ul>

Expand All @@ -49,11 +47,11 @@ export default function BasicExample() {
<Route exact path="/">
<Home />
</Route>
<Route path="/about">
<About />
<Route path="/products">
<Products />
</Route>
<Route path="/dashboard">
<Dashboard />
<Route path="/logos">
<Logos />
</Route>
</Switch>
</div>
Expand All @@ -70,20 +68,4 @@ function Home() {
<h2>Home</h2>
</div>
);
}

function About() {
return (
<div>
<h2>About</h2>
</div>
);
}

function Dashboard() {
return (
<div>
<h2>Dashboard</h2>
</div>
);
}
8 changes: 8 additions & 0 deletions src/Logos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'


export default () => {
return (
<div>Logos Place holder</div>
)
}
35 changes: 35 additions & 0 deletions src/Products.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react'

class Products extends React.Component {
constructor () {
super()
this.state = {
results: []
}
}

componentDidMount() {
this.callApi()
.then(res => this.setState({ response: res.express }))
.catch(err => console.log(err));
}

callApi = async () => {
const response = await fetch('http://localhost:3001/products');
const body = await response.json();
if (response.status !== 200) throw Error(body.message);

return body;
};

render () {
return (
<div>
<div>Products Place holder</div>
<div>{this.state.response}</div>
</div>
)
}
}

export default Products