1.5.3 • Published 4 years ago

silver-request v1.5.3

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

SilverRequest

A Fetch Wrapper with cache support that works with Redux

Getting Started

import SilverRequest from "silver-request";

    new SilverRequest(dispatch)
        .setUrl('http://github.com')
        .setEvent('Github Loaded')
        .send(); 

Installing

using yarn

yarn add silver-request

npm

npm install silver-request

Running the tests

simply run

yarn test

Usage

methodtypedefaultDescription
setLoggerfunctionnullset a function for loggin eg console.log
setRunOnSuccessfunctionnullset a function to run on successful request and to call this method is useful when you want plugin call desire event on successful request
setOnSuccessfunction or objectfunctionset a function to be called after receiving respond , this will override calling event
setOnErrorfunctionfunctionset a function to be called after error happen
setMethodstringGETset request type method
setIsCachablebooleanfalseis request is cachable or not
setUrlstringnull
setEventstringnullthe event name (Redux Event) that will be fired after successful request
setDataobjectnullthe data that will be sent by POST request
setNeedLoadingbooleanfalse
addAdditionalHeaderobjectnulladding additional header to request
setAdditionalHeaderobjectnullset additional header to request
setCacheTimeinteger30601000
setIsHardRefreshbooleanfalseif true , it will ignore existing cache , but will cache the reponse
sendcall this method to send the request

Static Properties

this properties will be applied to all request , set them in initializing you application

nametypedefaultDescription
additionalHeaderobjectobjectadding token for example
langstringen_US
cacheHandlerObjectLocalStorageCacheHandler
cacheTimeInteger30601000
globalOnSuccessfunctionnull
globalOnErrorfunctionnull
languageFileObjectObject

TODO

  • writing more test
  • writing more cache adapter
  • adding canceling request ability
1.5.3

4 years ago

1.5.2

4 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago