New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@wordpress/api-request

Package Overview
Dependencies
Maintainers
6
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wordpress/api-request - npm Package Compare versions

Comparing version 1.0.0-alpha.3 to 1.0.0

12

package.json
{
"name": "@wordpress/api-request",
"version": "1.0.0-alpha.3",
"version": "1.0.0",
"description": "Utility to call WordPress REST APIs",

@@ -12,3 +12,3 @@ "author": "The WordPress Contributors",

],
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/api-request/README.md",
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/api-fetch/README.md",
"repository": {

@@ -21,11 +21,5 @@ "type": "git",

},
"main": "build/index.js",
"module": "build-module/index.js",
"dependencies": {
"jquery": "^3.3.1"
},
"publishConfig": {
"access": "public"
},
"gitHead": "8827c049ec802471f51a5cb906d9096ffc1b4e48"
}
}

@@ -1,42 +0,5 @@

# @wordpress/api-request
This package has been deprecated in favor of `@wordpress/api-fetch`, please install the new package.
Wrapper around `jQuery.ajax` to call WordPress REST APIs.
## Installation
Install the module
```bash
npm install @wordpress/api-request --save
npm install @wordpress/api-fetch
```
## Usage
```js
import apiRequest from '@wordpress/api-request';
apiRequest( { path: '/wp/v2/posts' } ).then( posts => {
console.log( posts );
} );
```
### Middlewares
the `api-request` package supports middlewares. Middlewares are functions you can use to wrap the `wp.apiRequest` calls to perform any pre/post process to the API requests.
**Example**
```js
wp.apiRequest.use( ( options, next ) => {
const start = Date.now();
const result = next( options );
result.then( () => {
console.log( 'The request took ' + Date.now() - start );
} );
return result;
} );
```
The apiRequest package provides built-in middlewares you can use to provide a `nonce` and a custom `rootURL`.
<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc