Skip to content

Repository files navigation

[WIP] Wordpress SDK

npmGitHubBuild Status

Built with axios, this package provides a wrapper for Wordpress REST API for fetching data from wordpress hosted sites.

Installation

$ npm install wordpress-sdk --save

or if you use yarn

$ yarn add wordpress-sdk

Usage

Initializing configuration

import{wordpress}from'wordpress-sdk'// orconst{ wordpress }=require('wordpress-sdk')wordpress.initialize({// your wordpress rest api base URLurl: 'https://developer.wordpress.org/wp-json/wp/v2',})

Fetching posts

wordpress.allPosts().then(response=>{console.log(response.posts)}).catch(error=>{console.log(error.message)})

Or using async await

try{const{ posts }=awaitwordpress.allPosts()console.log(posts)}catch(error){console.log(error.message)}

Fetching categories

wordpress.allCategories().then(response=>{console.log(response.categories)}).catch(error=>{console.log(error.message)})

Or using async await

try{const{ categories }=awaitwordpress.allCategories()console.log(categories)}catch(error){console.log(error.message)}

About

No description, website, or topics provided.

Resources

Stars

7 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages