How to Reuse Methods from an App File in Pipedream?

This topic was automatically generated from Slack. You can find the original thread here.

:
How do you reuse methods from an app file?

Documentation read:

Whenever possible, reuse methods defined in the app file. If you need to use an API for which a method is not defined and it may be used in future components, define a new method in the app file.
But, how do you that? For example, gmail.app.mjs defines getAttachment and I would like to reuse that method in my own component (note that getAttachment calls _client ). Any tips?

Check out our actions, for example this one:

You import the file locally or from the npm package @pipedream/gmail

Add it as the first prop for auth

Then all methods from the app file will be available as: this.gmail.methodName()

Like this.gmail.getAttachment()

Thank you Andrew, this works.

Bottom line is to import the npm package and use it in props! :smile: