How to convert an object to JSON correctly in Angular 2 with TypeScript

前端 未结 5 1101
灰色年华
灰色年华 2020-12-23 13:40

I\'m creating an Angular 2 simple CRUD application that allows me to CRUD products. I\'m trying to implement the post method so I can create a product. My backend is an ASP.

5条回答
  •  隐瞒了意图╮
    2020-12-23 13:53

    In your product.service.ts you are using stringify method in a wrong way..

    Just use

    JSON.stringify(product) 
    

    instead of

    JSON.stringify({product})
    

    i have checked your problem and after this it's working absolutely fine.

提交回复
热议问题