-
Notifications
You must be signed in to change notification settings - Fork 6
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
refactor: 서버 주소 추가 및 서버가 주는 정보에 맞춰 코드 변경한다 #163
Changes from 4 commits
6e82e80
bbe6525
424cf02
6d5c4ad
8f31348
cf5c37c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -4,17 +4,27 @@ import { useExternalValue } from '@utils/external-state'; | |||||||||
|
||||||||||
import { selectedStationIdStore } from '@stores/selectedStationStore'; | ||||||||||
|
||||||||||
import { BASE_URL, INVALID_VALUE_LIST } from '@constants'; | ||||||||||
|
||||||||||
import type { StationDetails } from 'types'; | ||||||||||
|
||||||||||
export const fetchStationDetails = async (selectedStationId: number) => { | ||||||||||
const stationDetails = await fetch(`/stations/${selectedStationId}`, { | ||||||||||
const stationDetails = await fetch(`${BASE_URL}/stations/${selectedStationId}`, { | ||||||||||
method: 'GET', | ||||||||||
}).then<StationDetails>((response) => { | ||||||||||
}).then<StationDetails>(async (response) => { | ||||||||||
if (!response.ok) { | ||||||||||
throw new Error('[error] 충전소 세부 정보를 불러올 수 없습니다.'); | ||||||||||
} | ||||||||||
|
||||||||||
return response.json(); | ||||||||||
const data: StationDetails = await response.json(); | ||||||||||
|
||||||||||
const changedDataList = Object.entries(data).map(([key, value]) => { | ||||||||||
if (INVALID_VALUE_LIST.includes(value)) value = null; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
요게 더 좋지 않을까 하는 생각입니다! |
||||||||||
|
||||||||||
return [key, value]; | ||||||||||
}); | ||||||||||
|
||||||||||
return Object.fromEntries(changedDataList); | ||||||||||
}); | ||||||||||
|
||||||||||
return stationDetails; | ||||||||||
|
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.
상수로 분리해주세요