trello icon indicating copy to clipboard operation
trello copied to clipboard

Allow to specify fields with each request

Open pke opened this issue 2 years ago • 0 comments

I'd like this kind of signature to be supported:

getCardById("id", { checklists: "all" })

This could be implemented in a backward compatible way, as a new argument right before the callback.

The createQuery could be extended to accept an object as argument, which it mixes with key and token.

Trello.prototype.createQuery = function (options = {}) {
    return { ...options, key: this.key, token: this.token};
};
Trello.prototype.getCard = function (boardId, cardId, fields, callback) {
    // Back compatible: If last argument is a callback, then no fields are given
    if (typeof fields === "function") {
        callback = fields
    }
    if(boardId === null)
        return makeRequest(rest.get, this.uri + '/1/cards/' + cardId, fields, callback);
    return makeRequest(rest.get, this.uri + '/1/boards/' + boardId + '/cards/' + cardId, fields, callback);
};

Does this make sense?

pke avatar Nov 11 '21 01:11 pke