Skip to content

Commit

Permalink
feat: baseUrl 변경 및 api 통신 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
gogumalatte committed Nov 6, 2024
1 parent 32dfbeb commit 9a74e2b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VITE_BASE_URL=http://13.238.194.87:3001
VITE_BASE_URL=https://backbell.site:3001
20 changes: 12 additions & 8 deletions src/pages/main/message-input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Box, Textarea, IconButton } from "@chakra-ui/react";
import { ArrowUpIcon } from "@chakra-ui/icons";
import styled from "@emotion/styled";
import { useRef, useEffect, useState } from "react";
import axios from "axios";

interface MessageInputProps {
inputMessage: string;
Expand Down Expand Up @@ -39,14 +40,17 @@ export const MessageInput: React.FC<MessageInputProps> = ({
};

useEffect(() => {
// baseURL을 사용하여 백엔드에서 데이터 가져오기
fetch(`${baseURL}/api/test`)
.then((res) => res.json())
.then((data) => {
setResponse(data);
console.log("Fetched data:", data); // 받은 데이터 콘솔에 출력
})
.catch((error) => console.error("Error fetching data:", error));
const fetchData = async () => {
try {
const res = await axios.get(`${baseURL}/api/test`);
setResponse(res.data);
console.log("Fetched data:", res.data);
} catch (error) {
console.error("Error fetching data:", error);
}
};

fetchData();
}, [baseURL]);

useEffect(() => {
Expand Down

0 comments on commit 9a74e2b

Please sign in to comment.