How to call default API endpoint in custom plugin?

@Shekhar

I am using exactly what jamo advised but he is not showing how the route was created and what middleware he used

Can you please let me know how to adjust this route

export default {
    routes: [
        {
            method: 'GET',
            path: '/data',
            handler: 'datat.get',
            config: {
                policies: [],
                middlewares: [],
            },
        },
    ],
};

so that it works when called from a logged-in user in admin panel