- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试连接 react 管理员:https://github.com/marmelab/react-admin和 Node 服务器:https://github.com/hagopj13/node-express-mongoose-boilerplate
我在数据库中有用户,我可以使用 react 管理员登录。但是当我想显示用户列表时,我收到此错误:
fetch.js:39 GET http://localhost:4000/v1/users?filter=%7B%7D&range=%5B0%2C24%5D&sort=%5B%22createdAt%22%2C%22DESC%22%5D 401 (Unauthorized)
我不知道要在服务器上修改什么来接受请求。
我有点迷失了,我需要帮助才能开始,你有与react-admin一起使用的示例吗?我需要修改哪些文件?
更新:我在react-admin中的数据提供者
import { fetchUtils } from "react-admin";
import { stringify } from "query-string";
const apiUrl = "http://localhost:4000/v1";
const httpClient = fetchUtils.fetchJson;
export default {
getList: (resource, params) => {
console.log(params.pagination);
console.log(params.sort);
const { page, perPage } = params.pagination;
const { field, order } = params.sort;
const query = {
sort: JSON.stringify([field, order]),
range: JSON.stringify([(page - 1) * perPage, page * perPage - 1]),
filter: JSON.stringify(params.filter)
};
const url = `${apiUrl}/${resource}?${stringify(query)}`;
return httpClient(url).then(({ headers, json }) => ({
data: json,
total: parseInt(
headers
.get("content-range")
.split("/")
.pop(),
10
)
}));
},
getOne: (resource, params) =>
httpClient(`${apiUrl}/${resource}/${params.id}`).then(({ json }) => ({
data: json
})),
getMany: (resource, params) => {
const query = {
filter: JSON.stringify({ id: params.ids })
};
const url = `${apiUrl}/${resource}?${stringify(query)}`;
return httpClient(url).then(({ json }) => ({ data: json }));
},
getManyReference: (resource, params) => {
const { page, perPage } = params.pagination;
const { field, order } = params.sort;
const query = {
sort: JSON.stringify([field, order]),
range: JSON.stringify([(page - 1) * perPage, page * perPage - 1]),
filter: JSON.stringify({
...params.filter,
[params.target]: params.id
})
};
const url = `${apiUrl}/${resource}?${stringify(query)}`;
return httpClient(url).then(({ headers, json }) => ({
data: json,
total: parseInt(
headers
.get("content-range")
.split("/")
.pop(),
10
)
}));
},
update: (resource, params) =>
httpClient(`${apiUrl}/${resource}/${params.id}`, {
method: "PUT",
body: JSON.stringify(params.data)
}).then(({ json }) => ({ data: json })),
updateMany: (resource, params) => {
const query = {
filter: JSON.stringify({ id: params.ids })
};
return httpClient(`${apiUrl}/${resource}?${stringify(query)}`, {
method: "PUT",
body: JSON.stringify(params.data)
}).then(({ json }) => ({ data: json }));
},
create: (resource, params) =>
httpClient(`${apiUrl}/${resource}`, {
method: "POST",
body: JSON.stringify(params.data)
}).then(({ json }) => ({
data: { ...params.data, id: json.id }
})),
delete: (resource, params) =>
httpClient(`${apiUrl}/${resource}/${params.id}`, {
method: "DELETE"
}).then(({ json }) => ({ data: json })),
deleteMany: (resource, params) => {
const query = {
filter: JSON.stringify({ id: params.ids })
};
return httpClient(`${apiUrl}/${resource}?${stringify(query)}`, {
method: "DELETE",
body: JSON.stringify(params.data)
}).then(({ json }) => ({ data: json }));
}
};
感谢和问候
最佳答案
您在请求 header 中缺少 JWT
token ,这就是为什么您收到 401 代码,路由/v1/users 使用 auth 中间件保护 .get(auth('getUsers '), validate(userValidation.getUser), userController.getUser)
在 paths/v1/user.route.js
在 middlewares/auth.js 中 passport.authenticate('jwt', { session: false }, verifyCallback(req, resolve,拒绝, requiredRights))(req, res, next);
关于node.js - 带有 Node 服务器和react-admin的API URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60182711/
我只是希望我所有的管理页面都在 /admin 下. 我的主页在 /admin但是当我单击侧栏中的用户时,它会将路径更改为 /users而不是 /admin/users . 我正在使用 rea
我在端口 8011 上设置了一个 Django 服务器,并在端口 80 上有一个 nginx 作为子目录服务。 静态文件,不错。 页面,很好。 但是当我访问/subdirectory/admin/时,
我正在尝试使用 Flask 和 Flask-SuperAdmin 自定义我的 Admin View ,但是,索引 View 和 subview 显然没有使用相同的 is_accessible 方法:
我正在尝试配置我的 .htaccess,以便当有人导航到路径 /wp-admin/admin.php?page=something 时,路径 /wp-admin/something显示在浏览器中,内容
有没有办法整体禁用分页?我希望我的所有记录都显示在一个长列表中,而不是分成几页。我现在正在使用 ListGuesser,我已经尝试过 List 和 ListGuesser,但我无法禁用分页。实际上 r
在本地部署时,我的 RA 项目呈现良好,但是,当我将构建目录复制到 S3 存储桶进行部署时,它呈现的一切都一团糟。有时它有效,但大多数时候它呈现如下图所示。它在带有 AOR 的两种环境中都能正常工作。
我试图在 Datagrid 中显示Field这是多对多关系(中间表)。 我有这些表: 组 - group_subject - 主题 一个小组可以有多个科目 一个主题可以连接多个群组 group_sub
在用于显示用户列表的 Django 管理屏幕中(带有标题,选择要更改的用户),有用户名/电子邮件等字段和员工状态。我想将用户的事件状态添加到该显示中。 尽管大多数 django-admin 自定义问题
无论如何要检查所有 firebase 事务是否在 firebase-admin nodejs 脚本中完成,并正确断开与 firebase 的连接并退出 nodejs 脚本? 目前,即使在所有事务完成后
我正在尝试使用 react-admin 将数据发送到我的自定义 API。我想发送文件,我可以看到有,我想将该数据作为多部分表单数据发送。我遇到过the base64 encoding help pag
我正在尝试在admin部分中实现带有子表单的表单。 form = Fighter() subform = FighterFightHistory() //All of his fights 我的问题如
我在编辑表单中获取记录的“更新”值时遇到了很大的麻烦。我总是得到初始记录值,即使我有一个链接到正确记录源的输入,它应该更新它。 有没有其他方法来获取 SimpleForm 的值? 我有一个简单的编辑表
开发一个不需要翻译的管理员。有没有办法完全关闭它们。就像现在一样,对于诸如通知之类的事情,它们会显示,但我也会收到有关缺少翻译键的控制台警告。 最佳答案 除了 Frederik 的回答之外,以下是禁用
开发一个不需要翻译的管理员。有没有办法完全关闭它们。就像现在一样,对于诸如通知之类的事情,它们会显示,但我也会收到有关缺少翻译键的控制台警告。 最佳答案 除了 Frederik 的回答之外,以下是禁用
我有这样的模型: class User(db.Model): __tablename__ = 'users' __table_args__ = {'mysql_engine' : 'I
我已经使用 Media 类自定义了我的内联模型。 我想自定义内联字段集以实现两件事: 为每一行添加一个按钮 按下“添加新行”时从 javascript 代码运行 我试过覆盖 tabular.html
我的所有管理员/任何 url 正在呈现管理文件,但是当我尝试只点击管理员时,它显示 404 不在这条路线上。我可以为 url/admin 创建单独的路由,但这是他们的任何其他选项。这样我只能通过单一路
虽然我使用了许多图表,如 HighCharts、Charts.js、C3、D3,但是否有人尝试过或是否有一些关于如何将任何图表框架包含在 React-admin 中的文档?我看了一些,但看起来我们必须
react-admin 文档将资源的默认路由解释为: /posts/:id 映射到 PostEdit /posts/:id/show 映射到 PostShow 我希望我的应用程序默认为查看,并且仅当用
我正在使用 react-admin 前端框架,想知道是否有办法从路由中删除“#”。我正在使用 customRoutes 属性为我们的系统提供路由集合。 ``` 最佳答案 您可以创建自己的历
我是一名优秀的程序员,十分优秀!