Super.find returns undefined

System Information
  • Strapi Version: 4.1.7
  • Operating System: Ubuntu
  • Database: MySQL
  • Node Version: 16.2.0
  • NPM Version: 7.20.1
  • Yarn Version: 1.22.17

According to the developer docs, when extending a service you can use await super.find(params) to call the database before modifying the response. However, when I do this the response from that method is undefined.

My code is as follows, any pointers are greatly received!

module.exports = createCoreService('api::project.project', ({ strapi }) =>  ({

  async find(...args) {  

    let params = args[0],
        results = []

    // don't care about params, fetch all projects
    const { projects, pagination } = await super.find([]);

    // this line prints undefined

@markdturner I think you got data otherwise projects in the results.

const {data : projects, meta} = await super.find([])


Thanks @GavinXue, I tried your code but get an error data is undefined

Fixed it! Turns out the names of the variables are important, by changing it to the following it worked:

const { results, pagination } = await super.find(...args);
1 Like