c # – Converting IActionResult to an item that can be mapped in JS

I have the following unordered ReactJS list that is generated from the responses:

    {this.state.answers.map ((v, i) =>
  • {V}
  • )}

I receive the answers as follows:

handleSubmit (event) {
const url = "api /" + this.state.actionWith + this.state.button + this.state.value;
search (url, {
method: this.state.method
})
.then (response => response.json ())
.then (data => {
this.setState ({answers: data, entry: false, actionWith: "", method: "", button: "", placeholder: "", value: ""})
})
}

The controller looks like this:

[HttpGet]



public IActionResult ListTargets ()
{
var answer = _tlConnection.ListTargets ();
return Ok (answer);
}

And it works well when _tlConnection methods return something like IEnumerable.

The problem is that some methods return UInt for example. Then, this.state.answers is not something that can be mapped. I solve this as follows:

[HttpGet("{targetName}")]



public IActionResult getTargetID (string targetName)
{
var answer = new list() {_tlConnection.getTargetID (targetName) .ToString ()};
return Ok (answer);
}

But that's pretty hacky. Is there a more eloquent solution?

Is this a correct way to approach the JSON response in ReactJS in general?