wpcom-proxy-request
TypeScript icon, indicating that this package has built-in type declarations

7.0.6 • Public • Published

wpcom-proxy-request

Proxied cookie-authenticated REST-API and WP-API requests to WordPress.com

You likely want to use the high-level APIs in wpcom.js instead of using this module directly.

This module offers access to the WordPress.com REST-API and WP-API via a proxying <iframe> pointing to a special URL that proxies API requests on the host page's behalf.

It is intended to be used in the browser (client-side) via a bundler like browserify or webpack.

Installation

Install wpcom-proxy-request using npm:

npm install wpcom-proxy-request

Example

// Import wpcom-proxy-request handler
import proxy from 'wpcom-proxy-request';

proxy( { path: '/me' }, function ( err, body, headers ) {
	if ( err ) {
		throw err;
	}

	const div = document.createElement( 'div' );
	div.innerHTML = 'Your WordPress.com "username" is: <b>@' + res.username + '</b>';
	document.body.appendChild( div );
} );

Running tests

Compile and watch client-test application

make watch-test-app

Run server

make run-test-app

Open a tab pointing to http://calypso.localhost:3001/

License

MIT – Copyright Automattic 2014

Package Sidebar

Install

npm i wpcom-proxy-request

Weekly Downloads

2,378

Version

7.0.6

License

MIT

Unpacked Size

40.5 kB

Total Files

7

Last publish

Collaborators

  • macbre
  • yuliyan
  • mjangda
  • matticbot
  • a8c
  • blowery
  • ehg_
  • sgomes
  • tyxla
  • saroshaga
  • nejclovrencic
  • sirbrillig
  • chriszarate
  • robersongomes
  • johngodley
  • jeherve
  • daledupreez-a8c
  • t2dw4t
  • luismulinari
  • andrea-sdl
  • elazzabi
  • fmfernandes
  • sirreal
  • wwa
  • chihsuan
  • manzoorwanijk
  • msurdi-a8c
  • newspack
  • dsmartg
  • kthai15
  • bgrgicak
  • robertsreberski_a8c
  • artpi
  • gmjuhasz
  • kat3samsin
  • brunobasto
  • dhenridev
  • micbosia8c
  • mrmurphy
  • wpvip-bot
  • etobiesen
  • alshakero
  • arthur791004
  • dilirity
  • mattwest-a8c
  • mehmoodak
  • natalia.vidal
  • chriskmnds
  • oandregal
  • galatanovidiu
  • nylen
  • timmyc
  • gwwar
  • retrofox
  • tug
  • skeltoac
  • dmsnell
  • jsnajdr