nyx
nyx

Reputation: 25

Nest js using javascript how to log data from form data

Hi im new to nestJs and i making an API and i encountered a proble i have a vueJS project for front end and it will send a data using formData (axios) and now on my nestJs i want to log the formdata

const { Controller, Get, Post,Body, Req, HttpStatus } = require('@nestjs/common');
import { FileInterceptor, FilesInterceptor } from '@nestjs/platform-express';
const bodyParser = require('body-parser');

@Controller('sx')
class SxController {
  @Get()
  getSxRoot() {
    return { message: 'SX Group Root' };
  }

  @Get('/info')
  getSxInfo() {
    return { message: 'SX Group Information' };
  }

  @Post('/registerSx')
  createItem(@Req() req, @Body() body) {
    // Now data will contain the form data sent from the frontend
    // const { firstName, lastName, email, password } = JSON.parse(req.rawBody);
    const { email, firstname, lastname, password } = body;

   console.log()
  }
}

module.exports = SxController;

Upvotes: 0

Views: 19

Answers (0)

Related Questions