Gathering detailed insights and metrics for reqwest-without-xhr2
Gathering detailed insights and metrics for reqwest-without-xhr2
Gathering detailed insights and metrics for reqwest-without-xhr2
Gathering detailed insights and metrics for reqwest-without-xhr2
npm install reqwest-without-xhr2
Typescript
Module System
Node Version
NPM Version
JavaScript (95.09%)
HTML (4.56%)
Makefile (0.35%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
2,940 Stars
328 Commits
340 Forks
91 Watchers
3 Branches
44 Contributors
Updated on Jul 07, 2025
Latest Version
2.0.2
Package Id
reqwest-without-xhr2@2.0.2
Size
8.92 MB
NPM Version
2.13.2
Node Version
2.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
All over again. Includes support for xmlHttpRequest, JSONP, CORS, and CommonJS Promises A.
It is also isomorphic allowing you to require('reqwest')
in Node.js
through the peer dependency xhr2, albeit the original intent of this library is for the browser. For a more thorough solution for Node.js, see mikeal/request.
1reqwest('path/to/html', function (resp) { 2 qwery('#content').html(resp) 3}) 4 5reqwest({ 6 url: 'path/to/html' 7 , method: 'post' 8 , data: { foo: 'bar', baz: 100 } 9 , success: function (resp) { 10 qwery('#content').html(resp) 11 } 12}) 13 14reqwest({ 15 url: 'path/to/html' 16 , method: 'get' 17 , data: [ { name: 'foo', value: 'bar' }, { name: 'baz', value: 100 } ] 18 , success: function (resp) { 19 qwery('#content').html(resp) 20 } 21}) 22 23reqwest({ 24 url: 'path/to/json' 25 , type: 'json' 26 , method: 'post' 27 , error: function (err) { } 28 , success: function (resp) { 29 qwery('#content').html(resp.content) 30 } 31}) 32 33reqwest({ 34 url: 'path/to/json' 35 , type: 'json' 36 , method: 'post' 37 , contentType: 'application/json' 38 , headers: { 39 'X-My-Custom-Header': 'SomethingImportant' 40 } 41 , error: function (err) { } 42 , success: function (resp) { 43 qwery('#content').html(resp.content) 44 } 45}) 46 47// Uses XMLHttpRequest2 credentialled requests (cookies, HTTP basic auth) if supported 48reqwest({ 49 url: 'path/to/json' 50 , type: 'json' 51 , method: 'post' 52 , contentType: 'application/json' 53 , crossOrigin: true 54 , withCredentials: true 55 , error: function (err) { } 56 , success: function (resp) { 57 qwery('#content').html(resp.content) 58 } 59}) 60 61reqwest({ 62 url: 'path/to/data.jsonp?callback=?' 63 , type: 'jsonp' 64 , success: function (resp) { 65 qwery('#content').html(resp.content) 66 } 67}) 68 69reqwest({ 70 url: 'path/to/data.jsonp?foo=bar' 71 , type: 'jsonp' 72 , jsonpCallback: 'foo' 73 , jsonpCallbackName: 'bar' 74 , success: function (resp) { 75 qwery('#content').html(resp.content) 76 } 77}) 78 79reqwest({ 80 url: 'path/to/data.jsonp?foo=bar' 81 , type: 'jsonp' 82 , jsonpCallback: 'foo' 83 , success: function (resp) { 84 qwery('#content').html(resp.content) 85 } 86 , complete: function (resp) { 87 qwery('#hide-this').hide() 88 } 89})
1reqwest({ 2 url: 'path/to/data.jsonp?foo=bar' 3 , type: 'jsonp' 4 , jsonpCallback: 'foo' 5}) 6 .then(function (resp) { 7 qwery('#content').html(resp.content) 8 }, function (err, msg) { 9 qwery('#errors').html(msg) 10 }) 11 .always(function (resp) { 12 qwery('#hide-this').hide() 13 })
1reqwest({ 2 url: 'path/to/data.jsonp?foo=bar' 3 , type: 'jsonp' 4 , jsonpCallback: 'foo' 5}) 6 .then(function (resp) { 7 qwery('#content').html(resp.content) 8 }) 9 .fail(function (err, msg) { 10 qwery('#errors').html(msg) 11 }) 12 .always(function (resp) { 13 qwery('#hide-this').hide() 14 })
1var r = reqwest({ 2 url: 'path/to/data.jsonp?foo=bar' 3 , type: 'jsonp' 4 , jsonpCallback: 'foo' 5 , success: function () { 6 setTimeout(function () { 7 r 8 .then(function (resp) { 9 qwery('#content').html(resp.content) 10 }, function (err) { }) 11 .always(function (resp) { 12 qwery('#hide-this').hide() 13 }) 14 }, 15) 15 } 16})
url
a fully qualified urimethod
http method (default: GET
)headers
http headers (default: {}
)data
entity body for PATCH
, POST
and PUT
requests. Must be a query String
or JSON
objecttype
a string enum. html
, xml
, json
, or jsonp
. Default is inferred by resource extension. Eg: .json
will set type
to json
. .xml
to xml
etc.contentType
sets the Content-Type
of the request. Eg: application/json
crossOrigin
for cross-origin requests for browsers that support this feature.success
A function called when the request successfully completeserror
A function called when the request fails.complete
A function called whether the request is a success or failure. Always called when complete.jsonpCallback
Specify the callback function name for a JSONP
request. This value will be used instead of the random (but recommended) name automatically generated by reqwest.If you are still requiring support for IE6/IE7, consider including JSON3 in your project. Or simply do the following
1<script> 2(function () { 3 if (!window.JSON) { 4 document.write('<scr' + 'ipt src="http://cdnjs.cloudflare.com/ajax/libs/json3/3.3.2/json3.min.js"><\/scr' + 'ipt>') 5 } 6}()); 7</script>
1$ git clone git://github.com/ded/reqwest.git reqwest 2$ cd !$ 3$ npm install
Please keep your local edits to src/reqwest.js
.
The base ./reqwest.js
and ./reqwest.min.js
will be built upon releases.
1make test
Reqwest can be used as an Ender module. Add it to your existing build as such:
$ ender add reqwest
Use it as such:
1$.ajax({ ... })
Serialize things:
1$(form).serialize() // returns query string -> x=y&...
2$(form).serialize({type:'array'}) // returns array name/value pairs -> [ { name: x, value: y}, ... ]
3$(form).serialize({type:'map'}) // returns an object representation -> { x: y, ... }
4$(form).serializeArray()
5$.toQueryString({
6 foo: 'bar'
7 , baz: 'thunk'
8}) // returns query string -> foo=bar&baz=thunk
Or, get a bit fancy:
1$('#myform input[name=myradios]').serialize({type:'map'})['myradios'] // get the selected value
2$('input[type=text],#specialthing').serialize() // turn any arbitrary set of form elements into a query string
Use the request.ajaxSetup
to predefine a data filter on all requests. See the example below that demonstrates JSON hijacking prevention:
1$.ajaxSetup({ 2 dataFilter: function (response, type) { 3 if (type == 'json') return response.substring('])}while(1);</x>'.length) 4 else return response 5 } 6})
Reqwest can also be used with RequireJs and can be installed via jam
jam install reqwest
1define(function(require){ 2 var reqwest = require('reqwest') 3});
Reqwest can also be installed via spm
spm install reqwest
There are some differences between the Reqwest way and the jQuery/Zepto way.
jQuery/Zepto use type
to specify the request method while Reqwest uses
method
and reserves type
for the response data type.
When using jQuery/Zepto you use the dataType
option to specify the type
of data to expect from the server, Reqwest uses type
. jQuery also can
also take a space-separated list of data types to specify the request,
response and response-conversion types but Reqwest uses the type
parameter to infer the response type and leaves conversion up to you.
Reqwest also takes optional jsonpCallback
and jsonpCallbackName
options to specify the callback query-string key and the callback function
name respectively while jQuery uses jsonp
and jsonpCallback
for
these same options.
But fear not! If you must work the jQuery/Zepto way then Reqwest has a wrapper that will remap these options for you:
1reqwest.compat({ 2 url: 'path/to/data.jsonp?foo=bar' 3 , dataType: 'jsonp' 4 , jsonp: 'foo' 5 , jsonpCallback: 'bar' 6 , success: function (resp) { 7 qwery('#content').html(resp.content) 8 } 9}) 10 11// or from Ender: 12 13$.ajax.compat({ 14 ... 15})
If you want to install jQuery/Zepto compatibility mode as the default then simply place this snippet at the top of your code:
1$.ajax.compat && $.ender({ ajax: $.ajax.compat });
Happy Ajaxing!
No vulnerabilities found.
Reason
0 existing vulnerabilities detected
Reason
binaries present in source code
Details
Reason
Found 8/29 approved changesets -- score normalized to 2
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
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
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