[NestJS] redirect > Node/Flutter/Dart

본문 바로가기
사이트 내 전체검색

Node/Flutter/Dart

[NestJS] redirect

페이지 정보

작성자 sbLAB 댓글 0건 조회 32회 작성일 24-05-08 23:46

본문

auth.controller.ts 


import {
  Body,
  Controller,
  Get,
  Post,
  HttpCode,
  Render,
  HttpStatus,
  Header,
  Res,
  Redirect,
} from '@nestjs/common';
import { AuthService } from './auth.service';
import { UserDto } from 'src/user/dto/UserDto';
import { response } from 'express';

@Controller('auth')
export class AuthController {
  constructor(private authService: AuthService) {}

  @Get()
  @Render('auth/auth') //auth index page
  authView() {
    return this.authService.authView();
  }

  @Get('logout') //auth logout execution
  authLogOutExec() {
    const result = this.authService.authLogOutExec();
  }

  @Post('signup') //auth signup execution
  @HttpCode(HttpStatus.CREATED) //201
  //@Redirect('/', 301) //함수 실행종료후 리다이렉션
  //Common HTTP Status Codes
  //200 OK: The request was successful.
  //201 Created: The request was successful, and a new resource was created.
  //400 Bad Request: The server could not understand the request.
  //404 Not Found: The requested resource could not be found
  async authSignUpExec(@Body() userDto: UserDto, @Res() res) {
    const result = await this.authService.authSignUpExec(userDto);
    return res.redirect('/');
  }

OR

  @Post('signup') //auth signup execution
  @HttpCode(HttpStatus.CREATED) //201
  @Redirect('/', 301) //함수 실행종료후 리다이렉션
  //Common HTTP Status Codes
  //200 OK: The request was successful.
  //201 Created: The request was successful, and a new resource was created.
  //400 Bad Request: The server could not understand the request.
  //404 Not Found: The requested resource could not be found
  async authSignUpExec(@Body() userDto: UserDto, @Res() res) {
    const result = await this.authService.authSignUpExec(userDto);
//return res.redirect('/');

}
 


댓글목록

등록된 댓글이 없습니다.

회원로그인

접속자집계

오늘
137
어제
284
최대
1,279
전체
230,644

그누보드5
Copyright © sebom.com All rights reserved.