0

I have created the project (Angular/Typescript at FrontEnd, C# Controllers at Backend).

While I could run GET methods via:

http.get(originUrl + '/api/Poker/GetPokerValues').subscribe(result => {
            this.pokerValues = result.json() as PokerValue[];
});

to execute backend method:

[HttpGet("[action]")]
public IEnumerable<PokerValue> GetPokerValues()
{ //this code does execute
            return List;
}

I am still not able to run POST method via (Typescript) code:

var url = this._originUrl + '/api/Poker/SetPokerValue';
        this._http.post(url, dataToPass, {
            headers: headers
}).map(response => response.json()); 

at the controller:

[HttpPost("[action]")]
public ActionResult SetPokerValue(string someVar)
{//this code does not execute
    return Json("Success");
}

Do you have any idea what I did wrong to make it work?

Here is my code: https://github.com/kamilhawdziejuk/Scrum/blob/master/Angular/Controllers/PokerController.cs

https://github.com/kamilhawdziejuk/Scrum/blob/master/Angular/ClientApp/app/components/poker/poker.component.ts

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437

0 Answers0