Skip to content

Commit

Permalink
Add support for tags in searches
Browse files Browse the repository at this point in the history
  • Loading branch information
md-y committed Oct 1, 2022
1 parent d8f3712 commit 81f494e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ async function apiParameterRequest(baseEndpoint, parameterObject) {
if (typeof baseEndpoint !== 'string' || typeof parameterObject !== 'object') throw new Error('Invalid Argument(s)');
let params = new URLSearchParams();
for (let [key, value] of Object.entries(parameterObject)) {
if (value instanceof Array) value.forEach(elem => params.append(`${key}[]`, elem));
if (value instanceof Array) value.forEach(elem => {
if (typeof elem === 'object' && 'id' in elem) params.append(`${key}[]`, elem.id);
else params.append(`${key}[]`, elem)
});
else if (typeof value === 'object') Object.entries(value).forEach(([k, v]) => params.set(`${key}[${k}]`, v));
else params.set(key, value);
}
Expand Down

0 comments on commit 81f494e

Please sign in to comment.