From d05a908a2e3012c46d75ea8b748972b6450bec00 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 18 Aug 2023 15:04:46 +0200 Subject: [PATCH] Fix tagged posts signature and implementation according to docs --- lib/tumblr.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/tumblr.js b/lib/tumblr.js index be38bfb9..50fab584 100644 --- a/lib/tumblr.js +++ b/lib/tumblr.js @@ -791,12 +791,21 @@ class TumblrClient { /** * Gets posts tagged with the specified tag * - * @param {{tag:string; [param:string]: string|number}} params - optional parameters sent with the request + * @param {string} tag - The tag on the posts you'd like to retrieve + * @param {Record|TumblrClientCallback} [paramsOrCallback] - query parameters * @param {TumblrClientCallback} [callback] **Deprecated** Omit the callback and use the promise form * * @return {Promise|undefined} Request object, or Promise if {@link returnPromises} was used */ - taggedPosts(params, callback) { + taggedPosts(tag, paramsOrCallback, callback) { + const params = { tag }; + + if (typeof paramsOrCallback === 'function') { + callback = /** @type {TumblrClientCallback} */ (paramsOrCallback); + } else if (typeof paramsOrCallback === 'object') { + Object.assign(params, paramsOrCallback); + } + return this.getRequest('/v2/tagged', params, callback); } }