반응형 Spread2 유용한 자바스크립트 문법 응용 Truthy & Falsy - 자바스크립트는 자료형 상태에따라 참 거짓(TRUE,FALSE)로 평가하는 자료형들이 있다. const getName = (person) => { if (person === undefined || person === null) { return "객체가 아닙니다."; } return person.name; }; let person = null; const name = getName(person); console.log(name); 이와같이 작성할 수 있는것을 아래와같이 간소화 가능하다. const getName = (person) => { if (!person) { return "객체가 아닙니다."; } return person.name; }; let person = null;.. 2022. 7. 5. axios 여러개 요청하기 (멀티 리퀘스트) axios를 사용하다보면 get도 그렇고 post도그렇고 한번에 여러 api요청을 보내야 할 때가 있다. 그때마다 그냥 2~3거나 1~2개면 useEffect를 두번쓰거나해서 가져오곤 했지만 그냥 한번에 멀티리퀘스트를 보내는 방법이 있다. axios.all을 사용하는 것이다. function getUserAccount() { return axios.get('/user/12345'); } function getUserPermissions() { return axios.get('/user/12345/permissions'); } axios.all([getUserAccount(), getUserPermissions()]) .then(axios.spread(function (acct, perms) { // Bo.. 2022. 4. 2. 이전 1 다음 반응형