1.1.27 • Published 9 months ago

@jacraig/request v1.1.27

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
9 months ago

@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

1.1.27

9 months ago

1.1.23

10 months ago

1.1.22

10 months ago

1.1.26

10 months ago

1.1.25

10 months ago

1.1.24

10 months ago

1.1.19

11 months ago

1.1.18

11 months ago

1.1.17

11 months ago

1.1.21

10 months ago

1.1.20

11 months ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.12

12 months ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.16

11 months ago

1.1.15

11 months ago

1.1.14

12 months ago

1.1.13

12 months ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago