Creating a Trello PowerUp with an Express JS server listening to a Trello webhook. Is it possible to access Trello’s client.js or the Trello window object from the server.js that sets up the Express server and webhook listener? Example code referenced below.
I included the <script src="https://trello.com/1/client.js?key=[key]"></script>
in the index.html.
And would like to reference it in the following server.js code:
app.all('/', (req, res, next) => {
// where I would like to reference
// e.g. "Trello.post(path[, params], success, error)"
// e.g. "Trello.cards.get(id[, params], success, error)"
res.send('OK');
});
Thank you in advance for the help.
Not exactly, no. Keep in mind that client.js is a front-end javascript library. It is intended to be run in the context of a browser. It is a very lightweight wrapper for making HTTP requests to the Trello REST API, which is something that is easy to do from a backend context, as well, just not with this library.
Your server.js
is running node and so you’ll want to learn how to make HTTP requests from Node. Here is a good tutorial to get you started: https://nodejs.dev/learn/making-http-requests-with-nodejs
Hi Bentley, thank you for confirming what I expected. Currently I am using HTTP requests in the Node server.js. The reason I asked is because I’m looking to add to pluginData which appears to only be available through t.set(). Trying to store miscellaneous data on a card object.
Appreciate your help here.
Yes, using t.set()
and writing pluginData
can only be done from within the context of a Power-Up. Unfortunately, you can’t set pluginData
from a backend server.
Shucks. Well, appreciate the support here.
Trying to replicate a feature similar to the Trello Card Aging PowerUp. Any recommendations given the aforementioned restrictions?
Thanks again.
Resolved. Found solution in card badges.
1 Like