Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@highpoint/js-fetch

Package Overview
Dependencies
Maintainers
3
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@highpoint/js-fetch

HighPoint Fetch Library

  • 2.2.0
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
3
Weekly downloads
 
Created
Source

js-fetch

This is a small library to make using JavaScript's fetch a bit easier. It provides some utility functions to handle common request types.

The library assumes that responses will be in JSON format. If a response is not going to be in that format, then you can still use the library, but most of its usefulness will be gone.

Also included are some HighPoint-specific requirements like CSRF support and postMessages to parent informing it that the user is actively using child.

Installation

yarn add @highpoint/js-fetch

Usage

GET request

import { json } from '@highpoint/js-fetch';

(async () => {
  try {
    const jsonResponse = await json('https://api.example.com');
    console.log(jsonResponse);
  } catch (e) {
    // Handle the exception
  }
})();

POST Form

import { postForm } from '@highpoint/js-fetch';

(async () => {
  try {
    const jsonResponse = await postForm('https://api.example.com', {
      body: 'value1=1&value2=2'
    });
    console.log(jsonResponse);
  } catch (e) {
    // Handle the exception
  }
})();

POST JSON

import { postJSON } from '@highpoint/js-fetch';

(async () => {
  try {
    const jsonResponse = await postJSON('https://api.example.com', {
      body: {
        value1: 1,
        value2: 2
      }
    });
    console.log(jsonResponse);
  } catch (e) {
    // Handle the exception
  }
})();

Using <base> HREF

...
<base href="https://ps.example.com/psc/csdev/EMPLOYEE/SA/s/WEBLIB.ISCRIPT1.FieldFormula.IScript_Main">
...
import { json } from '@highpoint/js-fetch';

(async () => {
  try {
    const jsonResponse = await json('TermOptions');
    console.log(jsonResponse);
  } catch (e) {
    // Handle the exception
  }
})();

GET request would be made to https://ps.example.com/psc/csdev/EMPLOYEE/SA/s/WEBLIB.ISCRIPT1.FieldFormula.IScript_TermOptions.

FAQs

Package last updated on 06 Nov 2019

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

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