강의

멘토링

커뮤니티

Inflearn Community Q&A

wonders8080's profile image
wonders8080

asked

The Complete Guide to Vue.js - Practical Concepts Learned Through Practice and Refactoring

[Practice Guide] Method for Structuring axios API Functions and Practice Guide

강의에서 api를 따로 빼셨는데 얻는 이점이 뭐죠?

Resolved

Written on

·

220

1

2:05초에서는 created()에서 getNewsList();

함수 호출 하나로 axios.then.catch 코드를 줄일수 있다고 하셨는데,

12:00 초에서는

import 후에 fetchNewsList() 호출 후 , then.catch

그대로 있어서 결과론적으로 얻는 이점이 뭔지

모르겠습니다!

 

javascriptvue.js

Answer 1

0

captain님의 프로필 이미지
captain
Instructor

안녕하세요, 네 설명해 주신 것처럼

axios.get('users/1').then() 형태가

fetchUser().then() 형태로 축약된다로 봐주시면 될 것 같아요. 이후에 액시오스 공통 설정이나 타입스크립트 관점에서도 API 함수로 별도 분리되어 있는 형태가 유리합니다 :)

wonders8080's profile image
wonders8080

asked

Ask a question