Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensions : Methods are not included in strapi.plugins #8338

Closed
couragecowardlydog opened this issue Oct 15, 2020 · 4 comments
Closed

Extensions : Methods are not included in strapi.plugins #8338

couragecowardlydog opened this issue Oct 15, 2020 · 4 comments

Comments

@couragecowardlydog
Copy link

couragecowardlydog commented Oct 15, 2020

Describe the bug
I'm trying to add a function under strapi-plugin-upload but it's not getting exported
Followed the steps here , https://strapi.io/documentation/v3.x/concepts/customization.html#plugin-extensions

Steps to reproduce the behavior

  1. Create a folder after plugin id under extension, in my case I have created dir name upload
  2. Added a file with few functions

Expected behavior

  1. Functions are expected to be present under strapi. plugins, but its empty object

Screenshots
Screenshot 2020-10-15 at 12 08 08 PM

Code snippets

console.log(global.strapi.plugins)

Output
{}

System

  • Node.js version: v12.16.1
  • NPM version: 6.13.4
  • Strapi version: 3.2.1
  • Database: Mongo
  • Operating system: OS X
@lauriejim
Copy link
Contributor

This issue has been mentioned on Strapi Community. There might be relevant details there:

https://forum.strapi.io/t/customization-of-strapi-upload-plugin-logic/472/3

@MattieBelt
Copy link
Collaborator

Hey @vivekanandans,

It should be avaible with:

strapi.plugins['upload'].services.hello

Steps to reproduce:

  1. Create an fresh project yarn create strapi-app test-8338 --quickstart
  2. Create ./extensions/upload/services/hello.js:
module.exports = {
  sayHi() {
    strapi.log.debug('hi');      // console.log('hi');
  },
};
  1. Use strapi.plugins['upload'].services.hello.sayHi();
  2. image

@MattieBelt
Copy link
Collaborator

A handy tool to use is the strapi console: yarn strapi console.
It helps a lot with checking the structure (services & controllers) of the strapi object.
For example I used it to executed the function (see image from step 4).

@couragecowardlydog
Copy link
Author

Thanks @MattieBelt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants