@hamworks/wordpress-api-fetch
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@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);

Readme

Keywords

none

Package Sidebar

Install

npm i @hamworks/wordpress-api-fetch

Weekly Downloads

7

Version

0.1.0

License

GPL-2.0+

Unpacked Size

301 kB

Total Files

13

Last publish

Collaborators

  • kanakita
  • torounit
  • redamoon
  • chiilog
  • gouten5010
  • h2ham