@palasthotel/wp-fetch
v0.5.5
Published
Fetch data from a wordpress source. Works perfectly with headless plugin.
Downloads
5
Readme
wp-fetch
Use typesafe fetch requests to a wp-json REST api.
You need to install headless
plugin to use menus.
ALPHA-Version: function names and signatures may change.
Usage
Install package with npm i @palasthotel/wp-fetch --save
.
Have a look index.ts for the list available functions. As it is a typescript project method signatures are typed and should be easy to use even in a javascript environmen (but better use typescript).
Example
import {wpFetchPosts} from '@palasthotel/wp-fetch';
// in a async function context
const response = await wpFetchPosts("https://mySite.com/",{
type: "posts",
});
// without async function context
wpFetchPosts("https://mySite.com/",{
type: "posts",
}).then (response => {
});