Node.js 试图向Postman发出POST请求,但什么也没发生(NestJS和TypeORM)

Node.js 试图向Postman发出POST请求,但什么也没发生(NestJS和TypeORM),node.js,postgresql,typescript,nestjs,typeorm,Node.js,Postgresql,Typescript,Nestjs,Typeorm,我试图发出一个简单的POST请求,但没有任何反馈,新数据也不会进入数据库(Postgres)。我正在使用NestJS和TypeORM。当我尝试发出GET请求时一切正常。我是邮递员的新手,但我在网上找不到任何帮助 邮递员发帖请求(我也只使用用户名和密码进行了尝试): 类型为的实体架构: @Entity({ name: "user_user" }) export class User extends BaseEntity { @PrimaryGeneratedColumn() id: num

我试图发出一个简单的
POST请求
,但没有任何反馈,新数据也不会进入数据库(Postgres)。我正在使用NestJS和TypeORM。当我尝试发出
GET请求时
一切正常。我是邮递员的新手,但我在网上找不到任何帮助

邮递员发帖请求(我也只使用用户名和密码进行了尝试):

类型为的实体架构:

@Entity({ name: "user_user" })
export class User extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ unique: true })
  username: string;

  @Column()
  password: string;

  @Column()
  method: number;

  @Column()
  status: UserStatus;

  @CreateDateColumn({ type: "timestamp" })
  createdat: number;

  @UpdateDateColumn({ type: "timestamp" })
  updatedat: number;
}
控制员:

@Post()
async create(@Res() resp: Response, @Body() user: User) {
 const ret = await this.userService.save(user);
 resp.status(ret).send();
  }
最后是服务的保存功能:

hash1(password: string): string {
    var newpass = password + pepper;
    const salt = bcrypt.genSaltSync(10);
    return bcrypt.hashSync(sha3_512(newpass, undefined), salt);
  }

async save(user: User): Promise<number> {
    try {
      user.status = UserStatus.ACTIVE;
      user.method = 1;
      user.password = this.hash1(user.password);
      await this.userRepositroy.save(user);
      return HttpStatus.OK;
    } catch (e) {
      if (e instanceof QueryFailedError) return HttpStatus.CONFLICT;
      this.logger.error(e);
      return HttpStatus.BAD_REQUEST;
    }
  }
hash1(密码:string):string{
var newpass=密码+胡椒粉;
常量盐=bcrypt.genSaltSync(10);
返回bcrypt.hashSync(sha3_512(newpass,未定义),salt);
}
异步保存(用户:用户):承诺{
试一试{
user.status=UserStatus.ACTIVE;
user.method=1;
user.password=this.hash1(user.password);
等待这个.userRepositroy.save(user);
返回HttpStatus.OK;
}捕获(e){
如果(查询失败错误的实例)返回HttpStatus.CONFLICT;
此.logger.error(e);
返回HttpStatus.BAD_请求;
}
}

我希望你们能提供帮助:)

尝试在Postman中添加标题以接受json,如下所示:

"Content-Type": "application/json"

希望对您有用

尝试在Postman中添加标题以接受json,如下所示:

"Content-Type": "application/json"

希望对您有用

在中显示您的标题postman@A.khalifa没有任何特殊的标题。我只编辑了正文的原始部分。请尝试在您的文档中添加此标题内容类型:application/jsonpostman@A.khalifa非常感谢你!不客气,我会根据我们的讨论来写答案。请把你们的标题写出来postman@A.khalifa没有任何特殊的标题。我只编辑了正文的原始部分。请尝试在您的文档中添加此标题内容类型:application/jsonpostman@A.khalifa非常感谢你!不客气,我会根据我们的讨论写答案