Closed
Description
I'm using https://github.com/mgechev/angular2-seed for my angular2 app and I want to include wordpress-rest-api in a component file (typescript) but it's not working.
import * as WP from 'wordpress-rest-api/wp';
gave the error can't find module
I also tried require( 'wordpress-rest-api/wp' )
gave the error Unhandled rejection Error: Error on fetch for node.extend.js
export class AppCmp {
constructor(){
var WP = require( 'wordpress-rest-api/wp' );
var wp = new WP({ endpoint: 'http://localhost/murhaf/wp-json' });
wp.posts().then(function(data){
console.log(data);
}).catch(function( err ) {
console.log(err);
});
}
Thanks.
Metadata
Metadata
Assignees
Labels
No labels