inflearn logo
강의

Course

Instructor

Learn NestJS by following along

Handling results when a specific post is not found

특정 게시물을 찾을 때 없는 경우 에러 메세지 생성 에러

474

작성자 없음

0 asked

0

아래와 같이 NotFoundException()을 설정해줬는데요,

에러 메세지에 작성한 텍스트로 나오지 않습니다.

Delete는 message에 잘 찍혀서 나오는데 GET만 안되네요..

같은 문제 있으셨던 분 계시나요?


  getBoardById(id: string): Board {
    const found = this.boards.find((board) => board.id === id);

    if (!found) {
      throw new NotFoundException('게시물 없음');
    }

    return found;
  }
{
    "message": "Cannot GET /boards/wefqwefe",
    "error": "Not Found",
    "statusCode": 404
}
{
  "name": "project-test",
  "version": "0.0.1",
  "description": "",
  "author": "",
  "private": true,
  "license": "UNLICENSED",
  "scripts": {
    "build": "nest build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "start": "nest start",
    "start:dev": "nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/main",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest",
    "test:watch": "jest --watch",
    "test:cov": "jest --coverage",
    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
    "test:e2e": "jest --config ./test/jest-e2e.json"
  },
  "dependencies": {
    "@nestjs/common": "^10.0.0",
    "@nestjs/core": "^10.0.0",
    "@nestjs/platform-express": "^10.0.0",
    "class-transformer": "^0.5.1",
    "class-validator": "^0.14.0",
    "reflect-metadata": "^0.1.13",
    "rxjs": "^7.8.1",
    "uuid": "^9.0.0"
  },
  "devDependencies": {
    "@nestjs/cli": "^10.0.0",
    "@nestjs/schematics": "^10.0.0",
    "@nestjs/testing": "^10.0.0",
    "@types/express": "^4.17.17",
    "@types/jest": "^29.5.2",
    "@types/node": "^20.3.1",
    "@types/supertest": "^2.0.12",
    "@typescript-eslint/eslint-plugin": "^6.0.0",
    "@typescript-eslint/parser": "^6.0.0",
    "eslint": "^8.42.0",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-prettier": "^5.0.0",
    "jest": "^29.5.0",
    "prettier": "^3.0.0",
    "source-map-support": "^0.5.21",
    "supertest": "^6.3.3",
    "ts-jest": "^29.1.0",
    "ts-loader": "^9.4.3",
    "ts-node": "^10.9.1",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^5.1.3"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": "src",
    "testRegex": ".*\\.spec\\.ts$",
    "transform": {
      "^.+\\.(t|j)s$": "ts-jest"
    },
    "collectCoverageFrom": [
      "**/*.(t|j)s"
    ],
    "coverageDirectory": "../coverage",
    "testEnvironment": "node"
  }
}

postgresql jwt nestjs typeorm

Answer 1

0

liberty5569962

컨트롤러의 핸들러 메서드를 찾지 못하는 문제 같아 보여요.

로거 객체 질문

0

56

1

회원가입 기능 구현 버전 변경에 따른 코드수정(해당 사항은 업데이트 예정이 없나요?)

0

71

1

파일을 찾지 못하는 오류가 계속 뜹니다

0

98

1

services와 repository 파일에서 해야하는 작업

0

120

1

커스텀 파이프에서 value의 타입이 string 이 아닐때

0

165

1

nestjs 기본 구조 설명에서 궁금한게 있습니다.

0

175

0

typeorm ^10.0.2 버전 사용시 No metadata for "BoardRepository" was found. 오류 발생 해결방법.

3

271

1

Model과 Dto의 차이점을 좀 쉽게 알수 있을까요?

0

671

1

강의 자료 관련해서 글 남깁니다.

0

477

1

"ID로 특정 게시물 가져오기" 부분이 잘못되었습니다.

0

450

1

선생님 nestjs랑 Nextjs랑 같이 연동해서 작업하는거 어떻게 생각하시나요?

0

2504

1

쌤 근데 enum 말고 type 으로 타입선언해주면안될까요?

0

609

1

pgAdmin 4에서 데이터 베이스 만들어주기 부분

0

639

1

강의 자료 관련해서 질문있습니다.

0

462

2

port 5432 failed: recived invalid response to ssl negotiation

0

765

1

repository.ts 에서 method 를 가져 오고 싶은데, 해당 메소드가 없다고 뜨네요

0

398

1

컨트롤러에선 async/await 사용하지 않아도 되는 이유

1

689

1

마지막 강의 영상에서 배포 자료는 어디서 볼 수 있나요?

0

386

1

No repository for 질문

0

525

1

XML파일도 링크 공유해주시면 감사하겠습니다.

0

347

1

회원가입 기능 구현 중 오류가 났습니다.

0

497

1

NotFoundException

0

708

1

도와주세요 ㅠㅠ!!

0

1081

2

auth.service.ts에서 오류가 납니다

0

960

2