Skip to content

Commit

Permalink
.env
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelshoham committed Dec 20, 2023
1 parent 4b2179d commit 364cb38
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 21 deletions.
7 changes: 2 additions & 5 deletions src/api/posts.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import axios from 'axios';

const api = axios.create({
baseURL: 'http://127.0.0.1:3000',
baseURL: 'https://bb-projects-db-api-mego-program1.vercel.app',
});
const apiInpra = axios.create({
baseURL: 'http://127.0.0.1:5000'
})

export {api, apiInpra} ;
export {api} ;

16 changes: 7 additions & 9 deletions src/pages/Porjects/components/listProjects.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { api } from "../../../api/posts";


const token = localStorage.getItem("authToken");
console.log("token: " + token)
// console.log("token: " + token)

const { headers } = [
{
Expand All @@ -19,10 +19,10 @@ const { headers } = [
];

let userID = ''
// const userID = '4123r243f'


try {
const response = await api.get(`http://localhost:3000/users/self`,
const response = await api.get(`${import.meta.env.VITE_SERVER_URL}/users/self`,
{
headers: {
'Authorization': token,
Expand All @@ -34,16 +34,14 @@ try {
catch(error) {
console.error('error: ', error.message);
};
console.log('userID: ' + userID)


const UrlDataBoard = `http://localhost:3000/board/user/${userID}/read`;

const UrlDataBoard = `${import.meta.env.VITE_SERVER_URL}/board/user/${userID}/read`;
console.log(UrlDataBoard)

export default function ListProject() {

// const { param } = useParams();
// console.log(param);

const [projectsList, setProjectsList] = useState([]);

Expand All @@ -64,7 +62,7 @@ export default function ListProject() {
}

function handleDeleteItem(id) {
api.delete(`http://localhost:3000/board/${id}/delete`, { headers })
api.delete(`${import.meta.env.VITE_SERVER_URL}/board/${id}/delete`, { headers })
.then(() => {
fetchProjects();
})
Expand All @@ -88,7 +86,7 @@ export default function ListProject() {
<Button sx={{ color: "#F6C927" }}>
<AddIcon />
</Button>
</NavLink >
</NavLink>
{projectsList.map((item, index) => (
<Project
key={item._id}
Expand Down
13 changes: 6 additions & 7 deletions src/pages/create-project/components/createProject.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,25 @@ import Header from "../../Porjects/components/header";
import {api} from "../../../api/posts";
import { Project } from "../../Porjects/components/Project";

const UrlDataBoard = 'http://localhost:3000/board/create';
const UrlDataBoard = `${import.meta.env.VITE_SERVER_URL}/board/create`;
const headers = {
'Authorization': 'Happy',
'Content-Type': 'application/json; charset=utf-8'
};
const token = localStorage.getItem("authToken");
console.log("token: " + token)

let userID = ''
// const userID = '4123r243f'
let userID = '';

try {
const response = await api.get(`http://localhost:3000/users/self`,
const response = await api.get(`${import.meta.env.VITE_SERVER_URL}/users/self`,
{
headers: {
'Authorization': token,
'Content-Type': 'application/json; charset=utf-8',
}
})
console.log('user id:', response.data.result[0]._id);
// console.log('user id:', response.data.result[0]._id);
userID = response.data.result[0]._id;}
catch(error) {
console.error('error: ', error.message);
Expand Down Expand Up @@ -76,7 +75,7 @@ export default function CreateProject() {
}
}
function handleDeleteItem(id) {
api.delete(`http://localhost:3000/board/${id}/delete`, { headers })
api.delete(`${import.meta.env.VITE_SERVER_URL}/board/${id}/delete`, { headers })
.then(() => {
alert("the project has been deleted")
setSaved(false)
Expand Down Expand Up @@ -131,7 +130,7 @@ export default function CreateProject() {
>
Save
</Button>
</Card >
</Card>
</form>
);
}
24 changes: 24 additions & 0 deletions utils/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

0 comments on commit 364cb38

Please sign in to comment.