我想获得修改后的响应对象。例如,我不知道如何在没有 Angular 色的情况下获取用户对象。
默认响应是:
{
"id": 6,
"username": "username",
"email": "user@email.com",
"provider": "local",
"confirmed": true,
"blocked": false,
"role": {
"id": 2,
"name": "Authenticated",
"description": "Default role given to authenticated user.",
"type": "authenticated"
}
}
现在我想在没有 Angular 色属性的情况下获得相同的响应。
{
"id": 6,
"username": "username",
"email": "user@email.com",
"provider": "local",
"confirmed": true,
"blocked": false
}
最佳答案
目前,除非您更改权限插件提供的 UserController,否则您不能在 Rest API 中执行此操作,不推荐这样做。
那么你可以做的是使用Strapi提供的GraphQL插件,这样你就可以在客户端只查询你需要的字段。
关于如何使用 GraphQL 插件的文档是 here .
关于javascript - 修改 strapi 中的响应对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54840004/