Skip to content

Conversation

@GulSauce
Copy link
Member

@GulSauce GulSauce commented Jun 3, 2025

axiosInstance: 코드에도 설명 적어놓았습니다

한 곳에서 http요청을 관리합니다

  • base-url: axiosInstance 생성 시점에만 등록해주면 됩니다
  • method: 함수로 호출하면 됩니다: axiosInstance.get, axiosInstance.post등...
  • Content-Type: 기본적으로 application/json로 두었습니다 multipart라면
{
      isMultipart: true,
}

로 옵션을 주면 됩니다

한 곳에서 http응답을 관리합니다

  • 에러메시지 알림창을 띄워주는 코드를 한 곳에만 작성하면됩니다
  • 그후 Promise.reject를 호출하여 상위 스코프에 throw합니다

toast

alert창 대신 예쁜 모달을 띄워주는 라이브러리입니다
image
image

체크리스트

  • npm install
  • VITE_BASE_URL 바꾸어서 네트워크 에러 발생시켰을때 발생하는 알림창 확인
  • 마지막 문제입니다 알림창 확인
  • 코드 리뷰

method: "POST",
body: formData,
const res = await axiosInstance.post(`/s3/upload`, formData, {
isMultipart: true,
Copy link
Member Author

@GulSauce GulSauce Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Content-Type: 기본적으로 application/json로 두었습니다 multipart라면
{
      isMultipart: true,
}

로 옵션을 주면 됩니다

@GulSauce GulSauce requested a review from nech1234 June 3, 2025 00:41
@GulSauce GulSauce self-assigned this Jun 3, 2025
import axios from "axios";
const apiBaseURL = import.meta.env.VITE_BASE_URL;

const axiosInstance = axios.create({
Copy link
Member Author

@GulSauce GulSauce Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • base-url: axiosInstance 생성 시점에만 등록해주면 됩니다
  • method: 함수로 호출하면 됩니다: axiosInstance.get, axiosInstance.post등...
  • Content-Type: 기본적으로 application/json로 두었습니다 multipart라면
{
      isMultipart: true,
}

로 옵션을 주면 됩니다


axiosInstance.interceptors.response.use(
(response) => response,
(error) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 에러메시지 알림창을 띄워주는 코드를 한 곳에만 작성하면됩니다
  • 그후 Promise.reject를 호출하여 상위 스코프에 throw합니다

throw new Error(errText || "해설 불러오기 실패");
}
const data = await res.json();
const res = await axiosInstance.get(`/explanation/${problemSetId}`);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

method: 함수로 호출하면 됩니다: axiosInstance.get, axiosInstance.post등...

@nech1234 nech1234 merged commit d4d1e5a into main Jun 3, 2025
@lhoju0158 lhoju0158 deleted the ICC-54-error-message branch June 13, 2025 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants