node-wpapi
node-wpapi copied to clipboard
Document .root() method for accessing site name and description
Hey there,
I'd like to get the name and description through wpapi, how can I achieve this task?
If I send a GET request to wp-json I have these fields available.
But it seems there is no way to do that with wpapi.
Am I missing something?
Thank you in advance!
You may use .root():
site.root().then( siteInfo => {
console.log( siteInfo.name );
console.log( siteInfo.description );
} );
The root method executes an arbitrary request against the wp-json endpoint, so if you call it with no string argument, you get the endpoint itself. Your issue hear makes a good point that I don't think we actually document this anywhere, so I'm going to alter this issue to track adding those instructions. Thank you!