System Information
Strapi Version: 4.1.12
Operating System: Debian GNU/Linux 10
Database: mySQL 8.0.15
Node Version: 12.22.8
NPM Version: 6.14.15
Yarn Version: 1.22.17
Shouldn’t the code below change the default route /api/emissions ?
Nothing happens?
Can a good human being help me?
// /api/emission/controllers/emission.js
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::emission.emission'), ({ strapi }) => ({
async find(ctx) {
// some custom logic here
return { data: 'some data' };
},
});
I think , this is not allowed in strapi . you need to return object which should contain results
key in return statement
return { results: { dataKey: 'dataValue' }, pagination: {} }
at api side it will give below response (data field value is results field value in return and meta field value is 2nd object pagination)
{ "data": { "dataKey": "dataValue" }, "meta": { "pagination": {} } }
pagination field in response is optional if you can not give that is fine but results
key is mandatory otherwise it will give error .
eg return { results: { dataKey: 'dataValue' } }
it will api response as below
{ "data": { "dataKey": "dataValue" }, "meta": {} }