Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@gravityforms/request

Package Overview
Dependencies
Maintainers
11
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gravityforms/request

Utility to make WordPress REST API requests. It's a wrapper around window.fetch.

latest
Source
npmnpm
Version
5.0.2
Version published
Maintainers
11
Created
Source

Gravity Forms Request

Utility to make WordPress REST API requests. It's a wrapper around window.fetch

Installation

Install the module

npm install @gravityforms/request

Note: This package requires node 14.15.0 or later, and npm 6.14.8 or later. If needing support for IE11 make sure to include the fetch polyfill for that browser.

Overview

The request module abstracts away most of the pain of dealing with raw fetch.

Basic principles:

  • When a base_path needs variables in it, use the template function as seen in path map and pass those as "restParams" in your options
  • When you need query args appended for a get, pass them as "params" in your options object
  • When you want to POST set method: 'POST' and if passing json body set json: { data } in your options

Usage

Required in gravityforms.config.js in your project root:

module.exports = {
	requestConfig: {
		endpoints: {
			get_something: {
				path       : '/wp-json/gf/v2/get_something',
				rest_params: '',
				nonce      : null,
			},
		},
	}
	// other configs
}

Using the module:

import request from '@gravityforms/request';

const getSomething = async ( id ) => {
	const other_stuff = getSomeStuff( id );
	const response = await request( 'get_something', {
		method: 'POST',
		body: {
			some_data: { stuff: 'here', },
			other_stuff,
		},
	} );

	console.log( response.data );
};

Keywords

gravityforms

FAQs

Package last updated on 11 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts