A fast node request model, works very similar to request
module but way faster and no dependencies + it works in the browser!
npm install fasquest
const Fasquest = require('fasquest');
var options = {
uri: 'http://127.0.0.1/',
resolveWithFullResponse: true
}
Fasquest.request(options).then(res=>{
console.log('hey look I got a response')
})
import Fasquest from "fasquest";
var options = {
uri: 'http://127.0.0.1/',
resolveWithFullResponse: true
}
await Fasquest.request(options);
-
uri
(string): The URL to make the request to. -
method
(string): The HTTP method to use (default: 'GET'). -
qs
(object): An object containing query string parameters to be appended to the URL. -
headers
(object): An object containing request headers. -
body
(string|object): The body of the request. Ifjson
is set to true, this should be an object. -
json
(boolean): If true, sets theContent-Type
header toapplication/json
and stringifies the body. -
form
(object): An object containing form data. Sets theContent-Type
header toapplication/x-www-form-urlencoded
. -
timeout
(number): The number of milliseconds to wait for a response before timing out. -
resolveWithFullResponse
(boolean): If true, the full response object is returned, otherwise only the response body is returned. -
simple
(boolean): If true, only resolves the promise if the status code is 2xx otherwise throws an error. -
authorization
(object): An object containing authorization information. Supportsbasic
andbearer
tokens. -
redirect_max
(number): The maximum number of redirects to follow (default: 5). -
agent
(object): An object containing custom HTTP/HTTPS agents.
const Fasquest = require('fasquest');
var options = {
uri: 'http://127.0.0.1/',
method: 'POST',
qs: { key1: 'value1', key2: 'value2' },
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ key: 'value' }),
json: true,
form: { key: 'value' },
timeout: 5000,
resolveWithFullResponse: true,
simple: false,
authorization: { bearer: 'token' },
redirect_max: 10,
agent: { http: new http.Agent(), https: new https.Agent() }
}
Fasquest.request(options).then(res=>{
console.log('Response:', res)
}).catch(err=>{
console.error('Error:', err)
})
-
FR_Simple
: Thrown when thesimple
option is true and the response status code is not 2xx. -
FR_Request_<ErrorName>
: Thrown when there is an error with the request.<ErrorName>
will be replaced with the specific error name. -
FR_Request_Timeout
: Thrown when the request times out.
All notable changes to this project will be documented in this file. Dates are displayed in UTC.
- Update package.json
63b8da5
20 November 2024
- Update package.json
1644210
- Added back docs
78186ad
- Updated rollup which fixed the mjs version
c49a66b
18 April 2022
- Update index.js
5c6a245
8 February 2021
- Fixed bug with urls with
:
in their pathf123cfa
8 February 2021
- Default to text/plain if no content type is provided with body
dad6486
5 February 2021
- fix
a4a0518
20 October 2020
- Fixed issue with timeouts, removed default timeout logic if no timeout is set in options
5113537
22 September 2020
- Fixed tests and fixed issue with options being mutated
0e90d84
14 September 2020
- added a way to set the agent
25a8521
11 September 2020
- Fixed memory leak
433d5b3
11 September 2020
1 September 2020
- Added
npm publish
at the end of postversion7266053
1 September 2020
- Update index.mjs
1188bb9
1 September 2020
8 July 2020
- Fixed bug with redirect
638ace1
8 July 2020
- Update package.json
15ededc
8 July 2020
- Added browser es module version
c54e7cc
23 October 2019
12 September 2019
- 1.2.2 Fixed content-length bug
fb48137
12 September 2019
- 1.2.1 Fixed content-length bug
00f6b9d
11 September 2019