Ошибка useFetch axios не могу получить список пользователей с локального сервера в панель администратора
: Код для получения таблиц с локального API
import "./datatable.scss";
import { DataGrid } from "@mui/x-data-grid";
import { userColumns, userRows } from "../../datatablesource";
import { Link } from "react-router-dom";
import { useState } from "react";
import useFetch from "../../hooks/useFetch";
const Datatable = () => {
const {data, loading, error} = useFetch("/users")
const handleDelete = (id) => {
// setData(data.filter((item) => item.id !== id));
};
const actionColumn = [
{
field: "action",
headerName: "Action",
width: 200,
renderCell: (params) => {
return (
<div className="cellAction">
<Link to="/users/test" style={{ textDecoration: "none" }}>
<div className="viewButton">View</div>
</Link>
<div
className="deleteButton"
onClick={() => handleDelete(params.row.id)}
>
Delete
</div>
</div>
);
},
},
];
return (
<div className="datatable">
<div className="datatableTitle">
Add New User
<Link to="/users/new" className="link">
Add New
</Link>
</div>
<DataGrid
className="datagrid"
rows={data}
columns={userColumns.concat(actionColumn)}
pageSize={9}
rowsPerPageOptions={[9]}
checkboxSelection
getRowId={row=>row._id}
/>
</div>
);
};
export default Datatable;
Инфа о таблицах: datatablesource.js
export const userColumns = [
{ field: "id", headerName: "ID", width: 70 },
{
field: "user",
headerName: "User",
width: 230,
renderCell: (params) => {
return (
<div className="cellWithImg">
<img className="cellImg" src={params.row.img} alt="avatar" />
{params.row.username}
</div>
);
},
},
{
field: "email",
headerName: "Email",
width: 230,
},
{
field: "country",
headerName: "Country",
width: 100,
},
{
field: "city",
headerName: "City",
width: 100,
},
