Skip to content

Node module to fetch wp-json data from a wordpress instance

License

Notifications You must be signed in to change notification settings

palasthotel/wp-fetch

Repository files navigation

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 => {
    
});

About

Node module to fetch wp-json data from a wordpress instance

Resources

License

Stars

Watchers

Forks

Packages

No packages published