
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
A simple and generic way to handle RESTful API calls in your JavaScript application.
There are many libraries and utilities classes which provide RESTful implementation in JavaScript to handle API calls to server. Unfortunately, those other solutions, as good as they are, not always suits for everyone. Sometimes, the willing to do everything, just makes it more complex and harder to use.
This restful-js
solution, keeps stuff the most simple there is, and exposes a nice and easy interface for use in your app.
In case of customized logic, there are some hook methods you can override
npm install restful-js --save
fetch(url, options)
or get(url, options)
Sends HTTP GET request with the following parameters:
url: String
- the URL resource.
options: Object
- All of the ajax
options you would like to provide.
post(url, data, options)
Sends HTTP POST request with the following parameters:
url: String
- the URL resource.
data: Any
- The data you would like to send to the server.
options: Object
- All of the ajax
options you would like to provide.
put(url, data, options)
Sends HTTP PUT request with the following parameters:
url: String
- the URL resource.
data: Any
- The data you would like to send to the server.
options: Object
- All of the ajax
options you would like to provide.
destroy(url, options)
Sends HTTP DELETE request with the following parameters:
url: String
- the URL resource.
options: Object
- All of the ajax
options you would like to provide.
By default, an instance of the restful-js object is exported and ready to use.
For example:
import RestApi from 'restful-js';
// later on...
RestApi.fetch('some/url/resource').then(response => { /* handle response */ });
You may also get a class and instantiate it yourself and manage it's life-cycle.
For example:
import {RestfulAPI} from 'restful-js';
// later on...
let restfulAPI = new RestfulAPI();
restfulAPI.fetch(`${baseUrl}/users`).then(response => { /* handle response */ });
You may instantiate a class and give different handlers for XHR events.
For example:
import {RestfulAPI} from 'restful-js';
// later on...
let restfulAPI = new RestfulAPI({
errorResponseHandler: (xhr, textStatus, errorThrown) => {...}
ajaxStartHandler: () => {...},
ajaxStopHandler: () => {...}
});
You can easily customize some behavioural stuff by inheriting from the exported RestfulAPI
and add your own logic.
For example:
import {RestfulAPI} from 'restful-js';
class MyRestfulAPI extends RestfulAPI {
applySecurity(options, data){
// add some security logic
}
}
You may get a jQuery
reference for your own usage and event handling
For example:
import {RestfulAPI} from 'restful-js';
const restfulAPI = new RestAPIUtil();
// jQuery binary transport to download files through XHR
restfulAPI.$.ajaxTransport('+binary', () => {...})
For bugs and issues, please use the issues page.
jQuery.ajax
and use the global fetch
way! (waiting for full browser support)Sure! just fork this repository and join in!
0.7.1
jQuery
versionjQuery
module. jQuery
moved to peerDependencies
and devDependencies
to proper handlingFAQs
Simple and generic JavaScript class to handle REST API calls
The npm package restful-js receives a total of 11 weekly downloads. As such, restful-js popularity was classified as not popular.
We found that restful-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.