我暂时给了这个接口PUBLIC权限,用来测试
参考文档:https://www.npmjs.com/package/strapi-plugin-transformer
A plugin for Strapi that provides the ability to transform the API request and/or response.
npm install strapi-plugin-transformer
# OR
yarn add strapi-plugin-transformer
我的项目是ts类型,所以我创建的是plugins.ts
一旦插件被安装、配置和启用,任何对Strapi API的请求都将自动转换
此响应转换将从响应中删除attributes属性键,并将其所有属性上移一级。
module.exports = ({ env }) => ({
'transformer': {
enabled: true,
config: {
prefix: '/api/',
responseTransforms: {
removeAttributesKey: true,
removeDataKey: true,
}
}
},
});
访问:http://localhost:1337/api/terms-infos?populate=*
欢迎大家指出文章需要改正之处~
学无止境,合作共赢
手机扫一扫
移动阅读更方便
你可能感兴趣的文章