@Get

설명
express의 get 라우터와 같은 역할
Tags
 

예시

import { Controller, Get } from '@nestjs/common'; import { AppService } from './app.service'; @Controller() export class AppController { constructor(private readonly appService: AppService) {} @Get() getHello(): string { return this.appService.getHello(); } // url에서 /hello로 들어오면, sayHello 함수를 실행해야 한다는 것을 명시함. @Get('/hello') sayHello(): string { return 'hello'; } }
이제 localhost:3000/hello 로 접속하면 hello라는 문자열이 나온다.
notion image