-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add API client abstraction for easier fetch usage #24
Conversation
The latest updates on your projects. Preview: https://vitamin-c-bubkyff1q-poiu694s-projects.vercel.app
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest updates on your projects. Preview: https://vitamin-c-qs2o3wqsk-poiu694s-projects.vercel.app
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
우와아아아아아악 넘 예뻐요!!!! 고생하셨습니다!!!! 취향 관련 이야기와 질문 몇 개 남겼습니다 ㅎㅎ
src/app/page.tsx
Outdated
onClick={async () => { | ||
const res = await api.test.testPOSTSecureAPI() | ||
console.log(res) | ||
}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저는 보통 setState
하나 정도만 있을 때 inline으로 사용하는데, 어떤 기준으로 inline 코드를 작성하시는지 궁금합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이것도 보여주기용 코드라서 굳이 함수로 만들 생각은 안했었습니다~ 지워둘게요~!
src/utils/api/HTTPClient.ts
Outdated
} from './types' | ||
|
||
class HTTPClient { | ||
private baseUrl: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
브라우저 호환성을 위해, ECMAScript #
대신 TypeScript private
을 사용하신 건지 궁금합니다!
- tsconfig target을 es6로 설정하고
ECMAScript # private fields
를 사용해서 js 런타임에서도 완전한 private을 유지하기 - tsconfig target을 default(es3)로 가져가고,
TypeScript private
을 사용해서 js 런타임에서 private에 접근을 허용하되 브라우저 호환성을 높이기 Cf. https://www.typescriptlang.org/docs/handbook/2/classes.html#caveats
Cf. https://devblogs.microsoft.com/typescript/announcing-typescript-3-8-beta/#ecmascript-private-fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
큰 이유보다는 #을 붙이는 것보다 private을 붙이는게 더 가시적이라고 생각했어요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
타입 파일은 사용처 바로 옆에 위치시키는 걸 선호하시나요? 항상 타입을 어디에 위치시킬지 고민이라서 여쭤봅니다 ㅜ_ㅜ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분은 저도 고민인데여! 호출 부분이나, 로직과 멀리 떨어진 곳에서 types를 가져다 쓰진 않을 것 같아서 옆에 두었어요!
|
||
export interface RequestOptions { | ||
headers?: Record<string, string> | ||
body?: any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
body는 타입을 조금 더 제한하지 않아도 괜찮을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어떤 타입이 좋을까요?
src/utils/api/HTTPClient.ts
Outdated
|
||
public post<T>( | ||
url: string, | ||
body?: any, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RequestOptions
안에 body
가 포함되어있는데, 이 body
는 어떤 의도인지 궁금합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
axios 처럼 post(url, body, config)로 쓰려고 만든 부분입니다~! 뒤에 option에서 omit할게요
@@ -0,0 +1,4 @@ | |||
import { LocalStorageManager } from './localStorage' | |||
|
|||
export const AUTH_KEY = '@@auth-token' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
잘 모르겠어서 여쭤보는 건데, @
가 두 개면 어떤 걸 의미하는 건가요 ?_?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
별다른 의미는 없어용!
src/utils/api/apiClientFactory.ts
Outdated
secure, | ||
interceptors, | ||
}: { | ||
secure: boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional로 두고, default 값을 false로 두는 건 어떨까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
상관은 없을 것 같은데 어떤 부분에서 default를 false로 생각하신건지 궁금해요!
저는 secure인지 아닌지를 명시하고 싶어서 optional로 안두긴 했었습니다!
The latest updates on your projects. Preview: https://vitamin-c-bx57om5i4-poiu694s-projects.vercel.app
|
5382159
to
0d93589
Compare
The latest updates on your projects. Preview: https://vitamin-c-rgjnan43a-poiu694s-projects.vercel.app
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue Number
#23
Description
To Reviewers
api usage
Checklist
feat: add login page
)