Socket
Socket
Sign inDemoInstall

@jacraig/request

Package Overview
Dependencies
1
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @jacraig/request

Wrapper around fetch that adds functionality including caching, retry, and timeouts.


Version published
Weekly downloads
51
decreased by-28.17%
Maintainers
1
Install size
251 kB
Created
Weekly downloads
 

Changelog

Source

1.0.7 (2024-04-29)

Bug Fixes

  • bump rollup from 4.16.1 to 4.17.1 (d7bb5e5)

Readme

Source

@jacraig/request

NPM Publish

@jacraig/request is a powerful yet lightweight library designed to simplify HTTP requests using the native fetch API while adding functionality such as caching, retry logic, and timeouts. It aims to provide developers with a convenient and flexible solution for handling HTTP requests in JavaScript and TypeScript applications.

Features

  • Caching: Cache responses to improve performance and reduce network requests.
  • Retry logic: Automatically retry failed requests with customizable retry options.
  • Timeouts: Set timeouts for requests to prevent hanging and improve overall application responsiveness.

Installation

You can install @jacraig/request via npm:

npm install @jacraig/request

Usage

Here's a basic example of how you can use @jacraig/request to make a fetch request:


import { Request } from '@jacraig/request';

let returnValue = await Request.get('https://jsonplaceholder.somewhere.com/post.json').send();

In order to use caching, retry logic, or timeouts, you can use the extra methods on the returned Request object to set options:


import { Request, StorageMode } from '@jacraig/request';

let returnValue = await Request.get('https://jsonplaceholder.somewhere.com/post.json')
    .withStorageMode(StorageMode.StorageAndUpdate)
    .withTimeout(5000)
    .withRetryAttempts(3)
    .send();

If you prefer to use callbacks instead of promises, you can do so by passing a callback function to the onSuccess method:


import { Request } from '@jacraig/request';

Request.get('https://jsonplaceholder.somewhere.com/post.json')
    .onSuccess((response) => {
        console.log(response);
    })
    .send();

Documentation

For more detailed information on how to use @jacraig/request, please refer to the documentation on GitHub Pages.

License

@jacraig/request is licensed under the Apache 2.0 License

Keywords

FAQs

Last updated on 29 Apr 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc