Gathering detailed insights and metrics for react-detect-offline-api
Gathering detailed insights and metrics for react-detect-offline-api
Gathering detailed insights and metrics for react-detect-offline-api
Gathering detailed insights and metrics for react-detect-offline-api
Lightweight React hook for checking health of API services.
npm install react-detect-offline-api
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (92.05%)
JavaScript (7.95%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
36 Stars
147 Commits
9 Forks
3 Watchers
13 Branches
5 Contributors
Updated on Jan 26, 2025
Latest Version
1.0.3
Package Id
react-detect-offline-api@1.0.3
Unpacked Size
57.49 kB
Size
8.41 kB
File Count
8
NPM Version
6.4.1
Node Version
8.9.4
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
20
1npm install --save react-detect-offline-api
1import * as React from 'react' 2 3import ReactDetectOfflineAPI from 'react-detect-offline-api' 4 5class Example extends React.Component { 6 render () { 7 return ( 8 <ReactDetectOfflineAPI 9 apiUrl={'http://yourapiurl.com'} 10 checkInterval={5000} 11 onOnline={() => { 12 console.log('Online') 13 }} 14 onOffline={error => { 15 console.log(error && error.status ? 'Offline with error:' + error.status : 'Offline') 16 }} 17 initialStatusCallback={status => { 18 console.log('Initial status ', status ? 'online' : 'offline') 19 }} 20 resolveOnlineStatusFromPromise={response => response.status === 'healthy'} 21 render={({ online }) => 22 online 23 ? 24 <div>Online</div> 25 : 26 <div>Offline</div> 27 } /> 28 ) 29 } 30}
Please note that if a request is blocked by CORS policy, this component will not work.
Props | Required | Type | Description |
---|---|---|---|
apiUrl | true | string | API to check |
checkInterval | true | number | null | Polling interval. If null, there will be only one check on componentDidMount |
render | false | Function | We're using Render Props to render online of offline component. See an example for more info. |
onOnline | false | Function | Called once an API becomes online and was offline |
onOffline | false | Function | Called once an API becomes offline and was online, in case API call was unsuccessful, it gets error as parameter |
resolveOnlineStatusFromPromise | false | (response: Object) => boolean | Called to detect online status from response after successful API call, otherwise every successful API call would be considered as online status |
initialStatusCallback | false | (status: boolean) => void | Calledback that returnes an initial status |
MIT | Developed by Webscope.io
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 0/6 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
60 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More