Gathering detailed insights and metrics for @app-elements/with-request
Gathering detailed insights and metrics for @app-elements/with-request
Gathering detailed insights and metrics for @app-elements/with-request
Gathering detailed insights and metrics for @app-elements/with-request
npm install @app-elements/with-request
Typescript
Module System
Node Version
NPM Version
JavaScript (84.43%)
Less (15.57%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
543 Commits
12 Watchers
20 Branches
20 Contributors
Updated on Sep 02, 2022
Latest Version
3.0.19
Package Id
@app-elements/with-request@3.0.19
Unpacked Size
10.60 kB
Size
4.04 kB
File Count
6
NPM Version
lerna/3.22.1/node@v14.5.0+x64 (darwin)
Node Version
14.5.0
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
deprecated in favour of useRequest
Connect a Component to the result of an API request.
npm install --save @app-elements/with-request
1import withRequest from '@app-elements/with-request' 2 3// Here is a view that will render the result of our API request 4const User = ({ id, name, email }) => 5 <div key={`user-${id}`}> 6 <h1>{name}</h1> 7 <p>{email}</p> 8 </div> 9 10// Now we use withRequest to wrap the User component in a 11// Higher order Component (HoC) that will call the User Component 12// with the result of the API request. 13const enhance = withRequest({ 14 // Define the url that should be called. You can pass a string, or 15 // a function that's called with `props`. In this case, we'll use a 16 // function so we can get the `{ id }` prop passed down by our Router. 17 // Pretend the current URL is `users/3` where `3` is the `{ id }` 18 endpoint: ({ id }) => `https://jsonplaceholder.typicode.com/users/${id}` 19}) 20 21// Since withRequest is a HoC, it returns a function that expects 22// to be called with a Component as its only param. 23export default enhance(User)
Internally, withRequest
relies on a makeRequest
function which is a small wrapper around XHR that returns a promise and the xhr
reference. This allows withRequest
to abort ongoing requests if a new one is requested. (In the future this should be swapped for Fetch and AbortController)
Anyway, makeRequest
also let's you set an apiUrl
so you can make requests with just a pathname: auth/login
instead of https://my-cool-api.herokuapp.com/auth/login
.
To enable this:
1import { configure } from '@app-elements/with-request/makeRequest' 2 3configure({ apiUrl: 'https://my-cool-api.herokuapp.com' })
Prop | Type | Default | Description |
---|---|---|---|
endpoint | Function or String | None | The url to call, or a function that returns a the url to call. |
parse | Function | None | A function to parse the API response. If provided, will be called with the signature (result, prevResult) and whatever it returns will be cached as the result. |
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 1/26 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
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
71 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
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