Wp api node got `/wp/v2/posts` was not found error

421 views Asked by At

I got this error The requested URL /wp/v2/posts was not found on this server.

when trying to post a new post using WP api in node.js.

var WPAPI = require('wpapi')

var wp = new WPAPI({
    endpoint: 'http://example.com',
    username: 'test',
    password: 'test'
})
wp.posts()
    .create({
        title: 'Your Post Title',
        content: 'Your post content',
        status: 'publish'
    })
    .then(function(response) {
        console.log(response.id)
    })
    .catch(function(err) {
        console.log(err)
    })

The code is taken from here https://github.com/WP-API/node-wpapi

What's the possible causes of the issue? I'd tried to change the permalink to postname.

0

There are 0 answers