-2
Gustavo,
Make sure you have a valid form.value and request without Stringfy as Eduardo mentioned. Ideally, use a Game object - just as it is done in the service - and associate the value of the form with it.
export class Game{
public nome: string;
public constructor(init?: Partial<Game>) {
Object.assign(this, init);
}
}
onSubmit(form) {
Game game = new Game(form.value);
this.http.post<Game>('http://localhost:5000/api/games', game, this.options)
.subscribe(dados => Console.log(dados));
}
If the object is validated you can receive it properly in the service as follows.
[HttpPost]
public void Post([FromBody] Game game)
{
if(game != null)
{
GameDAO.Insert(game.nome);
}
}
The appropriate thing when asking a question is to insert the code snippet because it helps a lot in the answers.
Gustavo welcome to the stack overflow, please post the code as text according to the rules of the site
– Eduardo Vargas
Try to remove stringify when sending
– Eduardo Vargas
Gustavo, don’t forget to define a valid answer to your question.
– Daniel Accorsi