강의

멘토링

커뮤니티

Inflearn Community Q&A

codingking's profile image
codingking

asked

Node and React series that you can learn by following - Basic lecture

Node React Basics Lecture #13 Creating Auth Function

module.exports = { auth }; 관련

Written on

·

348

0

안녕하세요. 도중에 에러가 되서, 강의 돌려보면서 발견해서 지금은 문제없습니다만, 궁금해서 여쭤봅니다.

각 auth.js와 User.js에서 아래와 같이 모듈화 시켜주고있는데,

module.exports = { auth };
module.exports = { User };

{} 이게 없으면 모듈화가안되는건가요 ? 

그리고 index.js에서도.

const { auth } = require("./middleware/auth");
const { User } = require('./models/User');

꼭 변수병은 {}을 붙혀줘야 모듈화시킨걸 쓸수 있는건가요 ? 

reactnodejs

Answer 3

1

John Ahn님의 프로필 이미지
John Ahn
Instructor

ES module에 대해서 공부하시면 될것같습니다 ^^ 

1

John Ahn님의 프로필 이미지
John Ahn
Instructor

{} 이 안에 넣는 것은    그 안에 있는 함수나 변수들이  default로 가져오는게 아니여서 그럽니다 ^ ^ 

만약 auth 라는 함수가 default 로 export되는 값이라면 {} 없이   const auth =   ~~ 
이런식으로도 가능합니다 ~!!

0

codingking님의 프로필 이미지
codingking
Questioner

혹시 이거 관련해서 검색할려고 하면 검색키워드 같은거 알려주실수 있을까요 ? 

codingking's profile image
codingking

asked

Ask a question