How can get data with other field?

I
I have a collection that has a field “code_name”. Strapi help me to get data by /api/lap/:id but i want to get data by /api/lap/code_name

To retrieve CRM data enrichment from your Strapi collection using the code_name field instead of the id, you must create a custom route in Strapi. Here are the steps to achieve this:

Create a Custom Controller:
    In your Strapi project, navigate to the /api folder.
    Inside the relevant collection folder (e.g., /api/lap), create a new folder called controllers if it doesn't already exist.
    Create a JavaScript file in the controller's folder (e.g., lap.js) to define your custom controller.

Here's a basic example of what your custom controller might look like: 

// api/lap/controllers/lap.js
‘use strict’;

module.exports = {
async findOneByCodeName(ctx) {
const { code_name } = ctx.params;
const lap = await strapi.services.lap.findOne({ code_name });
return lap;
},
};
This code defines a findOneByCodeName function that takes the code_name parameter from the route and uses it to find a single lap record in your collection.