DEV Community

talhabutt111
talhabutt111

Posted on

wordpress api with JWT Authentication for WP-API

Hello i want implementing wordpress rest api in my nodejs express app.i am using JWT Authentication for WP-API plug in .but i cant not get all users from myapi call. following error i am facing when a call the route:

{code:"rest_no_route"data:Object {status: 404}message:"No route was found matching the URL and request method",}

Code for my rest wp route is following:

var WPAPI = require('wpapi'); var wp = new WPAPI({ endpoint: 'domain.com/wp-json' }); wp.myCustomResource = wp.registerRoute('jwt-auth/v1', '/token',
{ methods: 'POST', params: ['username', 'password'] })
wp.myCustomResource()
.username('myUserName').password('myPassword')
.then(res => console.log(res))
.catch(err => console.error(err))
});

i have already generate token and validate it from postman. i code it from this site "http://wp-api.org/node-wpapi/custom-routes/"

i already edit my .htaccess file and my plugin file( jwt-authentication-for-wp-rest-api/public/class-jwt-auth-public.php) but it does not helped me.

if some one resolve this error kindly help us

Top comments (1)

Collapse
 
webface profile image
webface

Im facing the exact same issue. Did you find a solution for this