Auth0 Home Blog Docs

How do I run an angularjs script to get a json token response?

angularjs

#1

Hello Everyone,

I am a total n00b and dont know what I am doing. I dont even know if this is the correct place to do this.

I have a script from a JWT plugin for wordpress. I need to parse this to get my token. I just dont know where to do this/how to do this. The script is below:

( function() {
var app = angular.module( ‘jwtAuth’, ] );

app.controller( ‘MainController’, function( $scope, $http ) {

var apiHost = 'http://yourdomain.com/wp-json';

$http.post( apiHost + '/jwt-auth/v1/token', {
    username: 'admin',
    password: 'password'
  } )

  .then( function( response ) {
    console.log( response.data )
  } )

  .catch( function( error ) {
    console.error( 'Error', error.data[0] );
  } );

} );

} )();

This came from : https://github.com/Tmeister/wp-api-jwt-auth/blob/develop/README.md

Any help would be greatly appreciated.


#2