Skip to content

Commit

Permalink
Merge pull request #57 from mlscvitpune/31_fetchProjectAPI
Browse files Browse the repository at this point in the history
feat:  integrated fetch projects
  • Loading branch information
gokhalevedant06 authored Dec 31, 2022
2 parents bf22f27 + 9689490 commit 56f855e
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 7 deletions.
77 changes: 71 additions & 6 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"axios": "^1.2.2",
"framer-motion": "^4",
"lorem-ipsum": "^2.0.4",
"node-sass": "^6.0.1",
Expand Down
25 changes: 24 additions & 1 deletion frontend/src/pages/Projects/Projects.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import EventBlogProjectMainSection from '../../components/EventBlogProjectMainSection/EventBlogProjectMainSection';
import { Box, Flex, Text } from '@chakra-ui/react';

Expand All @@ -8,7 +8,30 @@ import Data from './Data';
import ProjectSectionLeft from '../../components/ProjectSections/ProjectSectionLeft';
import ProjectSectionRight from '../../components/ProjectSections/ProjectSectionRight';

import axiosInstance from '../../utils/axiosInstance';

const Projects = () => {

const [projects, setProjects] = useState([])

useEffect(() => {
const fetchProjects = async () => {
await axiosInstance.get("/api/projects/getProjects").then((res) => {
if (res.status === 200)
setProjects(res.data.data);
})
}
fetchProjects();
console.log(projects);
},[]);

const fetchProject = async (id) => {
await axiosInstance.get(`/api/projects/getProject/${id}`).then((res) => {
if (res.status === 200)
return res.data.data;
})
}

return (
<>
<EventBlogProjectMainSection
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/utils/axiosInstance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import axios from 'axios'

const axiosInstance = axios.create({
baseURL: 'http://localhost:5001'
});

export default axiosInstance

0 comments on commit 56f855e

Please sign in to comment.