-
카테고리
-
세부 분야
백엔드
-
해결 여부
해결됨
Exception 포스트맨으로 확인 시 undefined 에러
24.01.24 16:22 작성 조회수 161
0
에러
[Nest] 48206 - 01/24/2024, 4:13:26 PM ERROR [ExceptionsHandler] You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.
at Object.createInvalidObservableTypeError (/Users/kwonyeji/Documents/nestStudy/a-nest/node_modules/rxjs/dist/cjs/internal/util/throwUnobservableError.js:5:12)
at Object.innerFrom (/Users/kwonyeji/Documents/nestStudy/a-nest/node_modules/rxjs/dist/cjs/internal/observable/innerFrom.js:93:36)
at doInnerSub (/Users/kwonyeji/Documents/nestStudy/a-nest/node_modules/rxjs/dist/cjs/internal/operators/mergeInternals.js:22:21)
at outerNext (/Users/kwonyeji/Documents/nestStudy/a-nest/node_modules/rxjs/dist/cjs/internal/operators/mergeInternals.js:17:70)
at OperatorSubscriber._this._next (/Users/kwonyeji/Documents/nestStudy/a-nest/node_modules/rxjs/dist/cjs/internal/operators/OperatorSubscriber.js:33:21)
at Subscriber.next (/Users/kwonyeji/Documents/nestStudy/a-nest/node_modules/rxjs/dist/cjs/internal/Subscriber.js:51:18)
at /Users/kwonyeji/Documents/nestStudy/a-nest/node_modules/rxjs/dist/cjs/internal/observable/innerFrom.js:120:28
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2.의심 코드
<main.ts>import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; import { HttpExceptionFilter } from './httpException.filter'; declare const module: any; async function bootstrap() { const app = await NestFactory.create(AppModule); const port = process.env.PORT || 3000; app.useGlobalFilters(new HttpExceptionFilter()); const config = new DocumentBuilder() .setTitle('Sleact API') .setDescription('Sleact 개발을 위한 API 문서입니다.') .setVersion('1.0') .addTag('connect.sid') .build(); const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup('api', app, document); await app.listen(port); console.log(`listening on port ${port}`) if (module.hot) { module.hot.accept(); module.hot.dispose(() => app.close()); } } bootstrap();
에러상황
회원가입 구현 후 에러 확인 하려고 포스트맨 으로 요청 시 200성공이 떨어지는게 아니라 해당 에러가 발생합니다. 값을 모두 넣어도 같은 에러가 발생하고 console 찍었을떄 아예 controller에 접근하지도 못했습니다. 설정이 잘못된 건지 잘 모르겠습니다 ㅠ
답변을 작성해보세요.
0
0
권예지
질문자2024.01.25
해결했습니다.
@Injectable()
export class UndefinedToNullInterceptor implements NestInterceptor {
intercept(context: ExecutionContext, next: CallHandler<any>): Observable<any> | Promise<Observable<any>> {
return
next
.handle()
.pipe(map((data) => (data === undefined ? null : data)));
}
}
위 처럼 return 다음에 줄바꿈을 했더니 자바스크립트에서 next 뒤에 ;로 인식해서 난 오류였습니다.
답변 2