Get all your public WordPress data through the WP API using a tree-shakable TypeScript library.
npm install @quickdevelopment/wp-js
// 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
});
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);
});
For more information about the library, see the documentation.
If you want to contribute to this project, see CONTRIBUTING for details.
MIT © Quickdevelopment. See LICENSE for details.
Generated using TypeDoc