
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
@bigcommerce/request-sender
Advanced tools
A simple library for sending HTTP requests.
To send a HTTP request.
import { createRequestSender } from '@bigcommerce/request-sender';
const requestSender = createRequestSender();
// GET request
requestSender.get('/foobars')
.then(({ body }) => console.log(body));
// POST request
requestSender.post('/foobars', { body: { name: 'Foobar' } })
.then(({ body }) => console.log(body));
To cancel a pending request
import { createRequestSender, createTimeout } from '@bigcommerce/request-sender';
const timeout = createTimeout(100);
const requestSender = createRequestSender();
requestSender.get('/foobars', { timeout })
.catch(({ status }) => console.log(status));
timeout.cancel();
To create a new instance of RequestSender
.
To create a new instance of Timeout
. If delay
is defined, the instance will automatically timeout after the specified period. Otherwise, it remains inactive until complete()
is called.
To submit a HTTP request using GET
, POST
, PUT
, PATCH
or DELETE
method. Alternatively, you can call sendRequest
and specify the request method as an argument.
To manually complete a timeout.
Request payload.
Default: null
URL encodes params.
Default: true
Request headers.
Default: { 'Accept': 'application/json, text/plain, */*', 'Content-Type': 'application/json', }
URL parameters. They get serialized as a query string.
Default: null
Request method. It's ignored if calling one of the convenience methods (get
, post
etc...).
Default: GET
Same as XMLHttpRequest.withCredentials
.
Default: true
Define if wish to timeout a request.
Default: null
Response body.
Default: null
Response headers.
Default: {}
Response status code. Return 0
if the request is cancelled.
Default: undefined
Response status text.
Default: undefined
Some useful commands
# To test
npm test
# To lint
npm run lint
# To release
npm run release
For more commands, please see package.json
MIT
FAQs
HTTP request client for browsers
The npm package @bigcommerce/request-sender receives a total of 0 weekly downloads. As such, @bigcommerce/request-sender popularity was classified as not popular.
We found that @bigcommerce/request-sender demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 12 open source maintainers collaborating on the project.
Did you know?
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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.