Skip to content

Commit

Permalink
fixed const error
Browse files Browse the repository at this point in the history
  • Loading branch information
parkersarahl committed Jul 10, 2024
1 parent fbaba12 commit 4f14f3d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useState } from "react";
import "./App.css";
import Todo from "./Todo";
import axios from "axios";
import { host } from "./constants";
import { hosts } from "./constants";

export type TodoDTO = {
id: number;
Expand All @@ -23,8 +23,8 @@ function App() {
});

useEffect(() => {
console.log("HOST", host);
axios.get(`http://${host}:3000/api/todos`).then((response) => {
console.log("HOST", hosts);
axios.get(`http://${hosts}:3000/api/todos`).then((response) => {
setTodos(response.data);
});
}, []);
Expand All @@ -43,7 +43,7 @@ function App() {
};

const addTodo = () => {
axios.post("http://localhost:3000/api/todos", newTodo).then((response) => {
axios.post(`http://${hosts}:3000/api/todos`, newTodo).then((response) => {
setTodos(response.data);
});
};
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/Todo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState } from "react";
import { TodoDTO } from "./App";
import axios from "axios";
import { FaEdit, FaCheck } from "react-icons/fa";
import { host } from "./constants";
import { hosts } from "./constants";

type Props = {
todo: TodoDTO;
Expand All @@ -29,7 +29,7 @@ const Todo = ({ todo, updateTodos }: Props) => {
const editTodo = (key: string, value: string | boolean) => {
const updatedTodo = { ...todo, [key]: value };
axios
.put(`http://${host}:3000/api/todos/${todo.id}`, {
.put(`http://${hosts}:3000/api/todos/${todo.id}`, {
todo: updatedTodo,
})
.then((response) => {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const hosts = window.location.hostname;

0 comments on commit 4f14f3d

Please sign in to comment.