Запрос при работе через MVC, который создал модели, затем контроллеры и вернул их в Razor для отображения. Все работало Теперь вам нужно написать приложение в. Net Core + React. Я не понимаю, как передать ему значение для отображения.
public class TableController : Controller
{
List<TableInfo> tableInfo = new List<TableInfo>();
public IActionResult Index()
{
using OracleConnection conn = DBUtils.GetDBConnection();
using OracleCommand cmd = new OracleCommand($"select ID, IP from updater_srv", conn);
conn.Open();
using (OracleDataReader dateReader = cmd.ExecuteReader())
{
while (dateReader.Read())
{
tableInfo.Add(new TableInfo
{
ID = Convert.ToString(dateReader.GetValue(0)),
IP = Convert.ToString(dateReader.GetValue(1)),
});
}
}
return View(tableInfo);
}
[HttpGet]
public IEnumerable<TableInfo> Get()
{
return tableInfo;
}
import React, {Component} из 'response';
класс экспорта Table extends Component {stati c displayName = Table.name;
constructor(props) {
super(props);
}
componentDidMount() {
axios.get('url').then(resopnse => {
this.setState({ data: response })
})
}
render() {
return (
<div>
<table>
<thead>
<th>ID</th>
<th>IP</th>
</thead>
<tbody>
this.state.data.map(item => {
return (
<tr>
<td>{item.ID}</td>
<td>{item.IP}</td>
</tr>
);
}
</tbody>
</table>
</div>
);
}
} Как правильно написать React, чтобы на странице отображалась таблица из базы данных.