
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
axios-crud provides a simple set of functions to do some CRUD requests to an API using axios.
yarn add axios-crud
or npm i -S axios-crud
class UserAPI {
doARequestToTheAPI() {
// do some stuff
}
}
and you need to have some CRUD functions for a model called "users" on the backend side, this is how the code would look like:
class UserAPI extends CrudModel {
constructor() {
super('users');
// Now you can access the CRUD methods in your class
}
doARequestToTheAPI() {
// do some stuff
}
}
The CrudModel constructor takes the model name as first paramater, and a config object as second parameter.
createCrudModel
which simply returns the set of CRUD functions. Takes the name of the model as first parameter and a config object as second parameter.You may want to set a global config to use in all of your CrudModel's.
This can be done using the config
method, which takes an object as parameter and merges the default config with the one passed as parameter.
You can set the following properties in the config object:
axios
. It is usefull if you want to use an abstraction of your networking library. This adapter must contain the same methods than axios has.modelNameAsAttribute
is true. Taking back our UserAPI example, our model is called "users". You may want to remove the last "s" in case of creation and edition (that's how it works with RoR). Setting this to true will then remove the last character from the model name when passing it as a key of the params object for the create / edit requests. Defaults to true.For edit and create, modelData will be associated with the key [modelName] key, and additionalData will simply be merged with the params object
args
are optional.
import { createCrudModel, config } from 'axios-crud';
const Model = createCrudModel('users');
// Get all users
Model.getAll().then((result) => console.log(result));
// Get a user data with id 10
Model.get(10).then((result) => console.log(result));
Run the example folder:
yarn
or npm i
then yarn start
or npm start
FAQs
Simple set of functions made for CRUD requests on REST API
We found that axios-crud 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.
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.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.