diff --git a/backend/server.js b/backend/server.js index 47484f8..757ab16 100644 --- a/backend/server.js +++ b/backend/server.js @@ -10,7 +10,7 @@ const app = express() const PORT = process.env.PORT || 5000 app.use(cors({ - origin:["*", "http://51.20.93.112:3000"],//"exp://192.168.8.182:8081" + origin:["*", "http://localhost:3000"],//"exp://192.168.8.182:8081" methods:["GET","POST"], credentials:true })) diff --git a/backend/src/controllers/addData.js b/backend/src/controllers/addData.js index 1e2307e..f44628c 100644 --- a/backend/src/controllers/addData.js +++ b/backend/src/controllers/addData.js @@ -5,6 +5,7 @@ const Item = require('../modals/Item') exports.addItem = async (req,res) =>{ try{ + console.log(req.body) const { name } = req.body const newItem = new Item({ name}) diff --git a/backend/src/routes/addRoutes.js b/backend/src/routes/addRoutes.js index c1a395e..f0b2551 100644 --- a/backend/src/routes/addRoutes.js +++ b/backend/src/routes/addRoutes.js @@ -3,7 +3,7 @@ const router = express.Router(); const addData = require('../controllers/addData'); -router.get('/items', addData.addItem) +router.post('/item', addData.addItem) module.exports = router; \ No newline at end of file diff --git a/frontend/src/App.js b/frontend/src/App.js index 40a3d30..a6b673a 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -8,7 +8,7 @@ function App() { const [items, setItems] = useState([]) useEffect(()=>{ - axios.get("http://51.20.93.112:5000/api/get/items").then(response => { + axios.get("http://localhost:5000/api/get/items").then(response => { setItems(response.data) }) @@ -25,7 +25,7 @@ function App() {