Skip to content

Consider adding a TypeScript definitions file #149

@MurhafSousli

Description

@MurhafSousli

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions