How to use the @wordpress/api-fetch.use function in @wordpress/api-fetch

To help you get started, we’ve selected a few @wordpress/api-fetch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Automattic / wp-calypso / client / gutenberg / editor / api-middleware / index.js View on Github external
export const applyAPIMiddleware = getSiteSlug => {
	// First middleware in, last out.

	// This call intentionally breaks the middleware chain.
	apiFetch.use( wpcomProxyMiddleware );

	apiFetch.use( debugMiddleware );

	apiFetch.use( wpcomPathMappingMiddleware( getSiteSlug ) );

	//depends on wpcomPathMappingMiddleware
	apiFetch.use( apiFetch.fetchAllMiddleware );

	apiFetch.use( apiFetch.createRootURLMiddleware( 'https://public-api.wordpress.com/' ) );
};
github Automattic / wp-calypso / client / gutenberg / editor / api-middleware / index.js View on Github external
export const applyAPIMiddleware = getSiteSlug => {
	// First middleware in, last out.

	// This call intentionally breaks the middleware chain.
	apiFetch.use( wpcomProxyMiddleware );

	apiFetch.use( debugMiddleware );

	apiFetch.use( wpcomPathMappingMiddleware( getSiteSlug ) );

	//depends on wpcomPathMappingMiddleware
	apiFetch.use( apiFetch.fetchAllMiddleware );

	apiFetch.use( apiFetch.createRootURLMiddleware( 'https://public-api.wordpress.com/' ) );
};
github pristas-peter / wp-graphql-gutenberg / src / index.js View on Github external
import { disableAutosaveMiddleware } from './Rest/rest';
import * as server from './Server/server';
import { registerBlockEditorPreview } from './PostTypes/block-editor-preview';
import { registerBlockRegistryUpdate } from './Blocks/registry';

const { IS_SERVER_PARAM } = server;

const params = new URLSearchParams( window.location.search );
const isServer = params.get( IS_SERVER_PARAM ) === 'true';
if ( isServer ) {
	if ( ! window.wp.wpGraphqlGutenberg ) {
		window.wp.wpGraphqlGutenberg = {};
	}

	window.wp.wpGraphqlGutenberg.server = server;
	apiFetch.use( disableAutosaveMiddleware );

	const { blockEditorReady, closeEditor } = server;

	domReady( () => {
		blockEditorReady().then( closeEditor );
		blockEditorReady().then( checkIframeAdmin );
	} );
} else {
	registerBlockRegistryUpdate();
	registerBlockEditorPreview();

	domReady( () => {
		const admin = document.getElementById( 'wp-graphql-gutenberg-admin' );

		if ( admin ) {
			render( , admin );