Skn0tt / nextjs-nestjs-integration-example

https://nextjs-nestjs-integration-example.now.sh
156 stars 36 forks source link

Throws error when i try to request with params in the url #4

Closed sridaradappt closed 3 years ago

sridaradappt commented 4 years ago

I just created a simple get method which requests id and returns some data. It returns data when compiling

this is my code in app.controller.ts

@Get(':id')
  findOne(@Param('id') employeeId: string, @Query() query: any) {
      return Math.random() * 10;
  }

error ] ./src/backend/app/app.controller.ts 11:10 Module parse failed: Unexpected character '@' (11:10) File was processed with these loaders:

Any Idea how to fix ?

Skn0tt commented 4 years ago

Could you provide a reproduction case? That would make it easier for me to debug :D

jhlabs commented 4 years ago

@sridaradappt you need to change the .babelrc file to the following and install the babel plugins:

{
  "presets": ["next/babel"],
  "plugins": [
    "babel-plugin-transform-typescript-metadata",
    ["@babel/plugin-proposal-decorators", { "legacy": true }],
    ["@babel/plugin-proposal-class-properties", { "loose" : true }]
  ]
}