node-wpapi
node-wpapi copied to clipboard
registerRoute doesnt work
I am testing against a headless wordpress app using https://ca.wordpress.org/plugins/jwt-authentication-for-wp-rest-api/ V1
I can test the plugin with postman and axios in react but cant get it to work here
var WPAPI = require("wpapi");
var wp = new WPAPI({ endpoint: "http://localhost:1038/wp-json" });
wp.login = wp.registerRoute("jwt-auth/v1", "/token", {
methods: "post",
params: ["username", "password"],
});
// wp.posts()
// .then(data => console.log(data)) // this works
// .catch(e => console.log);
wp.login()
.username("admin")
.password("password")
.then((res) => console.log(res))
.catch((err) => console.error(err));
Getting
{
code: 'rest_no_route',
message: 'No route was found matching the URL and request method',
data: { status: 404 }
}