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

@scoir/api

Package Overview
Dependencies
Maintainers
36
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scoir/api

This utility handles standard HTTP verb requests in JavaScript for use in an authenticated application. It also provides mechanisms to get PDF, CSV, & Zip files.

  • 7.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
252
increased by64.71%
Maintainers
36
Weekly downloads
 
Created
Source

Api

This utility handles standard HTTP verb requests in JavaScript for use in an authenticated application. It also provides mechanisms to get PDF, CSV, & Zip files.

Usage

initialize api instance

Pass in the fall back url function that will be used when a route is "unauthorized";

import apiFactory from '@scoir/api';
const fallBackUrlFn = () => '/login';
const api = apiFactory(fallBackUrlFn);
// use the api object

api instance

Use the instance to issue HTTP verbs

import apiFactory from '@scoir/api';
const fallBackUrlFn = () => '/login';
const api = apiFactory(fallBackUrlFn);
api.get(url).then(() => {
    ...
})
api.post(url, payload).then(() => {
    ...
})
api.put(url, payload).then(() => {
    ...
})
api.delete(url).then(() => {
    ...
})
api.patch(url, original, diff).then(() => {
    ...
})

getZip

Use to get a zip file at a given url. returns new Blob([data], {type: 'application/zip'}).

import apiFactory, { getZip } from '@scoir/api';
getZip(url).then((zipBlob) => {
    ...
})

getCSV

Use to get a CSV file at a given url. returns file blob.

import apiFactory, { getCSV } from '@scoir/api';
getCSV(url).then((CsvFileBlob) => {
    ...
})

getPdf

Use to get a Pdf file at a given url. returns byte array.

import apiFactory, { getPdf } from '@scoir/api';
getPdf(url).then((pdfByteArray) => {
    ...
})

FAQs

Package last updated on 24 Jan 2024

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