diff --git a/client/package.json b/client/package.json
index acc64ed..df92791 100644
--- a/client/package.json
+++ b/client/package.json
@@ -1,6 +1,7 @@
{
"name": "client",
"version": "0.1.0",
+ "proxy": "http://localhost:5000",
"private": true,
"dependencies": {
"axios": "^0.18.0",
@@ -18,6 +19,5 @@
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
- },
- "proxy": "http://localhost:5000"
+ }
}
diff --git a/client/src/components/Product/Product.jsx b/client/src/components/Product/Product.jsx
index e972fb2..8fdf18a 100644
--- a/client/src/components/Product/Product.jsx
+++ b/client/src/components/Product/Product.jsx
@@ -1,31 +1,40 @@
import React from 'react';
-import "./Product.css";
+import './Product.css';
import PropTypes from 'prop-types';
-const Product = props => {
- return (
-
-
-
-
-
-
-
- ${props.price}
-
-
-
-
- );
+const Product = (props) => {
+ return (
+
+
+
+
+
+
+
+ ${props.price}
+
+
+
+
+ );
};
Product.propTypes = {
- name: PropTypes.string.isRequired,
- photo: PropTypes.string.isRequired,
- price: PropTypes.number.isRequired,
- addToCart: PropTypes.func.isRequired
+ name: PropTypes.string.isRequired,
+ // photo: PropTypes.string.isRequired,
+ price: PropTypes.number.isRequired,
+ addToCart: PropTypes.func.isRequired,
};
-export default Product;
\ No newline at end of file
+export default Product;
diff --git a/client/src/store/actions/products.js b/client/src/store/actions/products.js
index 602b2c9..32777bf 100644
--- a/client/src/store/actions/products.js
+++ b/client/src/store/actions/products.js
@@ -1,14 +1,14 @@
import axios from 'axios';
import { FETCH_PRODUCTS } from './types';
-export const fetchProducts = () => async dispatch => {
- try {
- const res = await axios("/api/products/")
- dispatch({
- type: FETCH_PRODUCTS,
- payload: res.data.products
- })
- } catch (err) {
- console.log(err.message);
- }
-};
\ No newline at end of file
+export const fetchProducts = () => async (dispatch) => {
+ try {
+ const res = await axios('/api/products/');
+ dispatch({
+ type: FETCH_PRODUCTS,
+ payload: res.data.products,
+ });
+ } catch (err) {
+ console.log(err.message);
+ }
+};
diff --git a/config/keys.js b/config/keys.js
index 0b0b52a..b00b1d1 100644
--- a/config/keys.js
+++ b/config/keys.js
@@ -1,3 +1,3 @@
module.exports = {
- MONGO_URL: process.env.MONGO_URL
-};
\ No newline at end of file
+ MONGO_URL: process.env.MONGO_URL,
+};
diff --git a/routes/products.js b/routes/products.js
index 15c55b1..491c86f 100644
--- a/routes/products.js
+++ b/routes/products.js
@@ -4,8 +4,9 @@ const router = express.Router();
const Products = require('../models/Product');
router.get('/', async (req, res) => {
- const products = await Products.find({});
- res.json({ products });
+ const products = await Products.find({});
+ console.log('WORKING ROUTE');
+ res.json({ products });
});
-module.exports = router;
\ No newline at end of file
+module.exports = router;
diff --git a/server.js b/server.js
index fc5a2e3..b237171 100644
--- a/server.js
+++ b/server.js
@@ -13,18 +13,18 @@ const PORT = process.env.PORT || 5000;
app.use(require('helmet')());
app.use(require('cors')());
app.use(bodyParser.urlencoded({ extended: false }));
-app.use(bodyParser.json());
- // Routes
- app.use('/api/products', require('./routes/products'));
+// app.use(bodyParser.json());
+// Routes
+app.use('/api/products', require('./routes/products'));
// Production
if (process.env.NODE_ENV === 'production') {
- // Set static folder
- app.use(express.static('client/build'));
+ // Set static folder
+ app.use(express.static('client/build'));
- app.get('*', (req, res) => {
- res.sendfile(path.resolve(__dirname, 'client', 'build', 'index.html'));
- });
+ app.get('*', (req, res) => {
+ res.sendfile(path.resolve(__dirname, 'client', 'build', 'index.html'));
+ });
}
-app.listen(PORT, () => console.log(`Server running on port ${ PORT }`));
\ No newline at end of file
+app.listen(PORT, () => console.log(`Server running on port ${PORT}`));