# JAVASCRIPT CLIENT HANDLE for the WP REST-API

# What does this plugin do?

* Installs and Accesses the node-wpapi.js isomorphic client

* Provides the global variable 'wp', which is accessible and authenticated for use in all
javascript files in a WordPress installation to access the WP REST-API
both when an admin user is logged in and out of WordPress.

# Note:

 * This plugin includes code from the JSON Basic Authentication Plugin.
 * So JSON Basic Authentication plugin must not be installed else WordPress throws a conflict.


## Install
1. Download the plugin into your plugins directory.
2. Go to Plugins Dashboard. Activate 'JAVASCRIPT CLIENT HANDLE for the WP REST-API'
3. The Plugin is now activated, under it are the links:
 
            Settings | Deactivate | Edit
            
4. Click on this Settings link or on the WordPress Dashboard, Click on the "WPAPI Client Authentication" 
sub-menu of the Settings menu.
5. Enter any Administrator username and password, to validate Basic Authentication.
6. Go to your live site. e.g: http://wpsite.com or http://localhost:8080
7. Check your browser console: If your administrator's name is Matt, then you should see a console output:
"Matt! I am set to access the WP REST-API!"
8.  When the admin user logs out, cookie authentication is automatically enabled by default. You are all set. 
9. Open any .js script and start accessing the WP REST-API via the node-wpapi client

		e.g : To get all the posts on your WordPress model site. 
		wp.posts().embed().get().then(function( response ) {
			console.log( response );
			//do something with returned data
		    }); 

* See http://wp-api.org/node-wpapi/ or http://v2.wp-api.org/node-wpapi/ for more info.
        
        N.B: 
        * Mozilla Browser Console: Tools > Web Developer > Web Console
        * Chrome Browser Console: More Tools > Dveloper Tools > Console

## Use
* Installs and Accesses the node-wpapi.js isomorphic client
* Provides the global variable 'wp', which is accessible and authenticated for use in all
javascript files in a WordPress installation to access the WP REST-API
both when an admin user is logged in and out of WP.