@quickdevelopment/wp-js
TypeScript icon, indicating that this package has built-in type declarations

4.0.4 • Public • Published

@quickdevelopment/wp-js · npm version

Get all your public WordPress data through the WP API using a tree-shakable TypeScript library.

Table of Contents
  1. Installation
  2. Usage
  3. Coming up
  4. Contributing
  5. License

Installation

npm install @quickdevelopment/wp-js

Usage

Setting the Config

// src/main.ts
import { ConfigManager } from "@quickdevelopment/wp-js";

ConfigManager.getInstance({
    // Replace with your WordPress API URL
    apiUrl: 'https://developer.wordpress.org/wp-json/wp/v2',
    embed: true
});

Retrieve Posts

This is an example of how to retrieve posts from your WordPress site using the Post class.

import {Post, PostDataType} from "@quickdevelopment/wp-js";

const posts = new Post()

posts.fetch().then((posts: PostDataType[]) => {
  console.log(posts);
})
.catch((err) => {
  console.log(err);
});

Documentation

For more information about the library, see the documentation.

Coming up

  • [x] Add more API classes to retrieve data from the WP API
  • [ ] Examples of how to use the library in multiple contexts
  • [x] Add a documentation site

Contributing

If you want to contribute to this project, see CONTRIBUTING for details.

License

MIT © Quickdevelopment. See LICENSE for details.

Package Sidebar

Install

npm i @quickdevelopment/wp-js

Weekly Downloads

4

Version

4.0.4

License

MIT

Unpacked Size

53 kB

Total Files

39

Last publish

Collaborators

  • keygun-development