node-wpapi icon indicating copy to clipboard operation
node-wpapi copied to clipboard

Q: Create query params dynamically?

Open tiptronic opened this issue 4 years ago • 1 comments

Is there a way to create query-parameters dynamically/programmatically? E.g. by adding multiple

e.g instead:

posts().param('per_page', 99)

using an array:

posts().param(['per_page', 99],['author', 5])

or an object:

posts().param({ per_page: 99, author: 5, before: new Date( '2016-09-22' ) })

tiptronic avatar Jan 17 '22 14:01 tiptronic

Answer to self:

Just use this:

wp.posts().param({ per_page: 99, author: 5, before: new Date( '2016-09-22' ) })

(and next time, please read the code before asking 🙄)

tiptronic avatar Jan 17 '22 17:01 tiptronic