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

Document .root() method for accessing site name and description

Open CloudPower97 opened this issue 6 years ago • 1 comments

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!

CloudPower97 avatar May 15 '19 11:05 CloudPower97

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!

kadamwhite avatar May 27 '19 20:05 kadamwhite