How to replace the Strapi ID field with a slug field

Опубликовано: 17 Октябрь 2024
на канале: Strapi
10,949
156

In this video, we discuss how you can replace the Strapi findOne controller action to accept a slug instead of an id. This allows your url path slug to dictate which content is returned from Strapi and is useful when creating blogs with Strapi. This allows you to have user-friendly urls instead of having id’s in the url.

Chapters:

0:00:09 - Setting up a POST in the CMS
0:01:19 - Overriding the findOne Route
0:02:55 - Overriding the findOne Controller
0:05:45 - Testing Our Slug

Learn more with Brayden Girard -    / braydengirard  
---
Get started with Strapi: https://strapi.io/
Try live demo: https://strapi.io/demo
Strapi Blog: https://strapi.io/blog
Find help in our Forum: https://forum.strapi.io/
We are hiring! https://strapi.io/careers