dbeasy-js
v1.0.4
Published
This helps with database operations made easy
Downloads
60
Readme
dbeasy Usage Guide
A simple guide for using dbeasy Get and Post request helpers.
Installation
npm install dbeasy-jsimport Get from "dbeasy-js/Get";
import Post from "dbeasy-js/Post";try {
let result = await Get({
host: "https://postman-echo.com/get",
url: "",
onSuccess: (response, attempt) => {
// handle success
},
onError: (error, attempt) => {
console.log(`ERROR`, error);
},
});
console.log(`RESULT`, result);
} catch (err) {
console.log(`ERROR`, err);
}try {
let result = await Post({
host: "https://postman-echo.com",
url: "/post",
data: { firstName: "Ray" },
onSuccess: (response, attempt) => {
// handle success
},
onError: (error, attempt) => {
console.log(`ERROR`, error);
},
});
console.log(`RESULT`, result);
} catch (err) {
console.log(`ERROR`, err);
}Common Parameters
| Option | Type | Description |
| ----------- | -------- | ---------------------------- |
| host | string | Base URL of the API |
| url | string | Endpoint path |
| onSuccess | function | Called when request succeeds |
| onError | function | Called when request fails |
Post Request Only
| Option | Type | Description |
| ------ | ------ | ---------------------------- |
| data | object | Payload sent in request body |
