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

jo-fetch

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jo-fetch

JoFetch is a JavaScript tool that provides enhanced fetch functionality.

npmnpm
Version
1.0.1
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

JoFetch · License NPM CI

JoFetch is a JavaScript tool that provides enhanced fetch functionality.

There are a lot of functions in this tool, such as simple or integration version. Of course, all functions are successfully tested by Jest. By the way, hope this fetch function return any data jo(just) like how we call it.

Usage

import joFetch from 'jo-fetch'
let doc = await joFetch(
        'https://www.google.com',
        { method: 'GET' },
        {
            loadingTime: 10000,
            retryTimes: 5,
            retryDelay: 1000,
            returnType: 'html',
        }
    )
import { fetchDocument } from 'jo-fetch'
let doc = await fetchDocument(
        'https://www.google.com',
        { method: 'GET' }
    )

Installation

npm install jo-fetch

API

Integration function (joFetch)

joFetch(url, parem, config)
The following are the attributes in the parameter config.

AttributeTypeDescription
loadingTimenumberDefine the loading time for this fetch. If the fetch time exceeds this value, this fetch fails and an error is thrown.
retryTimesnumberDefine the number of times to retry to fetch it again when this fetch fails.
retryDelaynumberDefine the delay before each retry.
returnTypestringSpecify the type of returned data.

Simple function

The parameters, url and param, are same as window.fetch.

FunctionReturn TypeDescription
fetchJSON(url, param)PromiseReturn the result in json form after fetching.
fetchDocument(url, param)PromiseReturn the result as a document after fetching.
fetchInTime(url, param, time)PromiseReturn the result within a limit time. if not, this fetch fails and an error is thrown.
fetchAutoRetry(url, param, times, delay)PromiseReturn the result, and if the fetch fails, automatically retry to fetch within a limited number of times.

License

JoFetch is MIT licensed.

Keywords

fetch

FAQs

Package last updated on 14 Jan 2023

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