Looking at the way queries are constructed with this library, I feel that the param1, param2etc convention feels a bit arbitrary. Query levels (or directories, or what have you) will always start at the root (param1) and go until you don't specify another key; I'm not aware of a situation where you'd have a query for param1 and param3 without the intermediate param2.
Given this linearity, have you considered using an array for structuring these queries? As an example,
wpAPIResource.get([ 'users', wpAPIData.user_id ]);
// or
wpAPIResource.get([
'users',
wpAPIData.user_id
]);
This may avoid some confusion around the param1, param2 naming convention by flat-out removing it: You're now specifying a sequential number of URL parts that are assembled to create a final query.
Alternatively, you could introduce a more verbose query syntax in the manner of an ORM library like knex. That may be overkill for the time being!
Looking at the way queries are constructed with this library, I feel that the
param1
,param2
etc convention feels a bit arbitrary. Query levels (or directories, or what have you) will always start at the root (param1) and go until you don't specify another key; I'm not aware of a situation where you'd have a query forparam1
andparam3
without the intermediateparam2
.Given this linearity, have you considered using an array for structuring these queries? As an example,
would become
This may avoid some confusion around the param1, param2 naming convention by flat-out removing it: You're now specifying a sequential number of URL parts that are assembled to create a final query.
Alternatively, you could introduce a more verbose query syntax in the manner of an ORM library like knex. That may be overkill for the time being!