JS소스모듈
[과제 테스트]fetch함수 사용
JoyYellow
2022. 11. 10. 07:00
const API_END_POINT = API_END_POINT
export const request = async (url, option = {}) => {
try {
const fullUrl = `${API_END_POINT}${url}`
const response = await fetch(fullUrl, option)
if (respone.ok) {
const json = await response.json()
return json
}
throw new Error('API 통신 실패')
} catch (e) {
alert(e.message);
}
}