Access to params of WPRequest
See original GitHub issueIs there anyway to retrieve all params from a built WPRequest
?
What I’m looking for is an object like:
{
"id": 2,
"parent" : 1
}
Resulting from api.posts().id(1).revisions(2)
. And an object like:
{
"id": 2
}
Resulting from api.posts().id(2)
. But the closer I’ve got was
function getIndexes(request) {
/* eslint-disable no-param-reassign */
// Internal mutations inside reduce function
const foundIndexers = _reduce(request._path, (indexers, fragment, piece) => {
const id = _find(request._levels[piece], cmp => cmp.validate(fragment));
if (!id) return indexers;
const name = id.component.match(namedGroupRegex);
if (name) {
indexers[name[1]] = fragment;
}
return indexers;
}, { ...request._params });
return foundIndexers;
}
Since I’ve no access to routesTree, I can’t walk and assign the right name to each given _path
component.
Thank you
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How can I access parameters from a POST (or other HTTP ...
I have a JS component that (to the best of my knowledge) is making an appropriate fetch request (POST) to a C# server...
Read more >Get Query Strings and Parameters in Express.js - Stack Abuse
Your query parameters can be retrieved from the query object on the request object sent to your route. It is in the form...
Read more >How to access query string parameters - Node.js
Another way to access query string parameters is parsing them using the querystring builtin Node.js module. This method, however, must be passed ...
Read more >HTTP Requests - The PHP Framework For Web Artisans
Accessing The Request · App\Http\Controllers; · Illuminate\Http\Request; · UserController extends Controller · /** · @param Request $request · @param string $id · @ ......
Read more >How to Access Query Parameters in Javascript - Rad Devon
We can use the window 's location object to get the parameter string. The parameter string is in the search property. const queryParamsString...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@edygar This is awesome, I look forward to digging into it (and hopefully coming up with a solution that works for both of us) in the coming week.
Just so you know, I just published the very first version of the lib.
This current issue was poorly addressed here.
getIndexes
should grab any useful information for finding an entity, my wish as that I could extract the params with the right params name.