element-api icon indicating copy to clipboard operation
element-api copied to clipboard

Fixed order based on slug

Open thunder87 opened this issue 1 year ago • 0 comments

Description

Unable to order entries based on the order the slugs are received.

Steps to reproduce

  1. Copy below entries.json and view the entries.json output in the browser.
  2. Order will be the same regardless of how the slugs are ordered.

Additional info

return [
    'endpoints' => [
        'entries.json' => function() {
            $slugs = Craft::$app->getRequest()->getRequiredQueryParam('slugs');

              return [
                  'elementType' => Entry::class,
                  'criteria' => [
                      'slug' => $slugs
                  ],
                  'transformer' => function (Entry $entry) {
                      return [
                          "title" => $entry->title,
                      ];
                  },
              ];
        }
    ]
]
  • Craft version: 4.9.0
  • PHP version: 8.1.27
  • Database driver & version: MySQL 8.0.33
  • Plugins & versions: Element-api 4.1.0

thunder87 avatar May 13 '24 09:05 thunder87