작성
·
659
2
계속 붙잡고 있어도 안되서 헬프를 칩니다.. 뭐가 문제인거죠..?
auth.js 파일에서 findbytoken을 만드는데 계속 안되기만 합니다.
TypeError: User.findByTokenis not a function
at auth (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\middleware\auth.js:8:10)
at Layer.handle [as handle_request] (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\layer.js:95:5)
at C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\index.js:281:22
at Function.process_params (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\index.js:335:12)
at next (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\index.js:275:10)
at cookieParser (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\cookie-parser\index.js:71:5)
at Layer.handle [as handle_request] (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\index.js:317:13)
at C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\index.js:284:7
at Function.process_params (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\index.js:335:12)
at next (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\index.js:275:10)
at C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\body-parser\lib\read.js:130:5
at invokeCallback (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\raw-body\index.js:224:16)
ㄱ계속 이 문구만 뜨고요 함수가 아니라는데 저는 함수를
user.js에 만들었고.. 아 이게 무슨 문제일까요..
auth.js
user.js
좋은 강의 항상 감사드립니다.
답변 7
2
userSchema.methods.findByToken= function(token,cb){
가 아니라
userSchema.Static.findByToken= function(token,cb){
이엇나 그랫을거에요
2
1
0
0
0
0
어떤게 문제였나요? 저도 같은 findByToken not a function에러가 뜨네요
type error같은데 못찾곘어요