-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature/#49 채팅방 수정
- Loading branch information
Showing
10 changed files
with
415 additions
and
88 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// src/utils/api.js | ||
import { instance } from "./instanceAuth"; // 설정된 Axios 인스턴스 임포트 | ||
|
||
export async function postMemberData(data) { | ||
const url = `/api/auth/member?name=${encodeURIComponent(data.koreanName)}`; | ||
|
||
try { | ||
const response = await instance.post(url, data); // Axios 인스턴스 사용 | ||
return response.data; // 서버로부터 받은 응답 데이터를 반환 | ||
} catch (error) { | ||
console.error("회원정보 보내기 실패:", error); | ||
throw error; // 오류를 호출자에게 다시 던짐 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import axios from "axios"; | ||
|
||
// Axios 인스턴스 생성 | ||
export const instance = axios.create({ | ||
baseURL: import.meta.env.VITE_AUTH_BASE_URL, | ||
withCredentials: true, | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
timeout: 10000, // 10초 타임아웃 설정 | ||
}); | ||
|
||
// 요청 인터셉터 추가 | ||
instance.interceptors.request.use( | ||
(config) => config, | ||
(error) => Promise.reject(error) | ||
); | ||
|
||
// 응답 인터셉터 추가 | ||
instance.interceptors.response.use( | ||
(response) => response, | ||
(error) => { | ||
if (error.code === "ECONNABORTED") { | ||
console.log("Request timeout"); | ||
window.location.href = "/error"; // 타임아웃 시 에러 페이지로 리디렉션 | ||
} | ||
return Promise.reject(error); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.