Installations
npm install @ansonhkg/wordpress-api
Developer Guide
BETA
Typescript
No
Module System
CommonJS
Releases
Unable to fetch releases
validate.email 🚀
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Download Statistics
Total Downloads
2,351
Last Day
7
Last Week
9
Last Month
13
Last Year
246
Bundle Size
13.72 kB
Minified
4.66 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.0.8
Package Id
@ansonhkg/wordpress-api@0.0.8
Unpacked Size
894.22 kB
Size
88.25 kB
File Count
307
Total Downloads
Cumulative downloads
Total Downloads
2,351
Last Day
0%
7
Compared to previous day
Last Week
0%
9
Compared to previous week
Last Month
-62.9%
13
Compared to previous month
Last Year
-51.4%
246
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
3
Dev Dependencies
2
What is this?
A utility library to fetch wordpress content through REST API.
Installation
npm
yarn
Usage
1const api = require('@ansonhkg/wordpress-api') 2const wp = api.fetch('http://your-wordpress-api.com/wp-json/wp/v2'); 3 4async function run () { 5 6 // return top (default) 10 posts 7 var posts = await wp.getPosts("&slug=your-post-title-most-likely"); 8 9 // return categories by slug 10 var categories = await wp.getCategories("&slug=news"); 11 12 // return posts by category slug 13 var posts = await wp.getPostsByCategorySlug({ 14 slug: "news", 15 page: 1, 16 per_page: 5 17 }); 18 19 // extract categories from Post object 20 var post = posts.data[0] 21 var categories = wp.extractCategories(post) 22 23 // extract tags from Post object 24 var post = posts.data[0] 25 var tags = wp.extractTags(post) 26 27 // extract author info from Post object 28 var post = posts.data[0] 29 var author = wp.extractAuthor(post) 30} 31 32run(); 33
Vue - Install it globally
1import wp from '@ansonhkg/wordpress-api' 2 3Vue.use({ 4 install(Vue) { 5 Vue.prototype.$wp = wp.fetch('http://your-wordpress-api.com/wp-json/wp/v2') 6 }, 7}) 8
Now, you can use
1this.$wp.getPosts() 2 3// eg. in created hook 4async created(){ 5 const data = await this.$wp.getPosts(); 6}
in your Vue component.

No vulnerabilities found.

No security vulnerabilities found.