Cannot access a strapi service created with hyphen "-"

System Information
  • Strapi Version: 3.1.4
  • Operating System: MACOS Big Sur
  • Database: MongoDB
  • Node Version: v12.17.0
  • NPM Version: 6.14.4
  • Yarn Version: 1.22.5

Hi Everyone,

I am certain the following question is super easy to answer.
We have created a content type “address_unit”. Strapi generated the folders /api/address-unit

I am busy writing a custom controller but unable to access the “address_unit” service as per below (Cannot read property ‘create’ of undefined):

entity = await;

If I console.log the object I get the following result:

  'address-unit': {
    find: [Function: find],
    findOne: [Function: findOne],
    count: [Function: count],
    create: [Function: create],
    update: [Function: update],
    delete: [Function: delete],
    search: [Function: search],
    countSearch: [Function: countSearch],
    __filename__: 'address-unit.js'

Obviously, I cannot write:

entity = await;


entity = await'address-unit'.create(dataAddress);

What should I do in this case?

1 Like['address-unit']

Thanks @sunnyson
I am ashamed. Should have known I could use standard object key to invoke. :rofl: :man_facepalming:

this actually helped today ! thanks!

Thanks good job :grinning: