【问题标题】:How to only get last 30 days of contntent in strapi如何在strapi中仅获取最近30天的内容
【发布时间】:2022-06-20 22:30:35
【问题描述】:

希望到目前为止你们都度过了愉快的一周。

我试图只在我的 strpi 后端获取最近 30 天的帖子,但似乎无法弄清楚...

这是我目前所拥有的:

`/api/updates?created_at_gte=2022-04-03&created_at_lte=2022-05-03` 

但由于某种原因,它仍在获取所有帖子...

实际上我希望它在发布日期之前发布,但有没有办法做到这一点?

提前谢谢你

【问题讨论】:

    标签: reactjs api axios request strapi


    【解决方案1】:

    您的查询参数错误。

    const qs = require('qs');
    const query = qs.stringify({
      filters: {
        username: {
          $eq: 'John',
        },
      },
    }, {
      encodeValuesOnly: true,
    });
    
    await request(`/api/users?${query}`);
    // GET /api/users?filters[username][$eq]=John
    

    这里还有更多例子:https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/filtering-locale-publication.html#filtering

    【讨论】:

      猜你喜欢
      • 2016-08-20
      • 1970-01-01
      • 1970-01-01
      • 2014-05-29
      • 2022-01-22
      • 2016-11-12
      • 2021-10-28
      • 1970-01-01
      • 2022-01-20
      相关资源
      最近更新 更多