I am new to web api and react. I was trying to pass a method IHttpActionResult in the following way in visual studio
namespace specialRequest.Controllers
{
[RoutePrefix("api/observation")]
public class T_SVRS_FormController : ApiController
{
[HttpPost]
[Route("GetLocations")]
public IHttpActionResult GetLocations(string jwt)
{
OracleConnection connOra = new OracleConnection(Utilities.LGS_DB);
try
{
DataTable oraDataTable = new DataTable();
string query = "select RDN_DESTN_DESC from strdba.t_rail_destn";
OracleCommand oraCmd = new OracleCommand(query, connOra);
connOra.Open();
// create data adapter
OracleDataAdapter oraDA = new OracleDataAdapter(oraCmd);
// this will query your database and return the result to your datatable
oraDA.Fill(oraDataTable);
return Ok(oraDataTable);
}
catch (Exception ex)
{
// conn1.Close();
connOra.Close();
return Content(HttpStatusCode.NoContent, "Something went wrong");
}
}
}
}
I dont need the parameter jwt can I pass IHttpActionResult without a parameter. When I try to remove the parameter the editor shows error saying atleast 1 accssesor is required.
Also since there is a parameter my dropdown is not picking up this value of the following code in react
getLocations = () => {
var Items = [];
axios.post('api/observation/GetLocations').then(response => {
response.data.map(item => {
var obj = new Object();
Items.push(obj);
});
this.setState({ locations: Items });
});
console.log('Response:' + this.state.locations);
};
How do I pass IHttpActionResult without a parameter so that my code in react works. Please help and please understand that I am new to this and in a pickle any help will be appreciated