LimCRUD is library for create simple CRUD request for my project. This is use default fetch API from javascript.
First, add to your page.
<script src="link-to-this-directory/limcrud.js" />
Change link-to-this-directory
to your own directory.
Then, initialize when page onload.
window.onload = () => {
const crud = new LimCRUD("auth-string");
}
Change auth-string
with your own bearer string when needed. You have to include the "Bearer" string, e.g. "Bearer 98e2y938hd9f948f4f43".
Done! You're ready to go!
You can perform some create, read, update, and delete (CRUD) operation with REST API. Here's list of them.
- Create with create() and createPlain().
- Read with read().
- Update with update() and updatePatch().
- Delete with update().
Here's some example that frequently I used.
crud.create({
url: "http://localhost/yourweb/api/user",
data: {
"name": "Sujono",
"age": 20
},
name: "user"
});
crud.read({
url: "http://localhost/yourweb/api/user/1"
});
crud.updatePatch({
url: "http://localhost/yourweb/api/user/1",
data: {
"column": "age",
"value": 20
},
name: "user"
});
crud.delete({
url: "http://localhost/yourweb/api/user/1"
});