0.1.0 • Published 3 years ago

@hamworks/wordpress-api-fetch v0.1.0

Weekly downloads
-
License
GPL-2.0+
Repository
github
Last release
3 years ago

@hamworks/wordpress-api-fetch

Customized @wordpress/api-fetch

use globalThis.fetch .

Installation

Install the module

npm install @hamworks/wordpress-api-fetch --save

Usage

import apiFetch from '@team-hamworks/wordpress-api-fetch';

// GET
let posts = await apiFetch( { path: '/wp/v2/posts' } )
console.log( posts )

// POST
let posts = await apiFetch( {
	path: '/wp/v2/posts/1',
	method: 'POST',
	data: { title: 'New Post Title' },
} )
console.log( posts )

ES Modules

import apiFetch from 'https://cdn.pika.dev/@hamworks/wordpress-api-fetch';
const posts = await apiFetch( { path: '/wp/v2/posts' } )
console.log( posts )

Middlewares

fetchAllInParallelMiddleware

A modification of fetchAllMiddleware to perform requests in parallel.

import apiFetch from 'https://cdn.pika.dev/@hamworks/wordpress-api-fetch';
apiFetch.use( apiFetch.fetchAllInParallelMiddleware );
const posts = await apiFetch( { path: '/wp/v2/posts?per_page=-1' }, { mode: 'cors'} );
console.log(posts);
0.1.0

3 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago