1.0.2 • Published 6 months ago

crudfactor v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
6 months ago

CRUD Factor

Overview

The CRUD Factor package provides a simple and convenient way to handle CRUD (Create, Read, Update, Delete) operations in web applications. It exports a factory function called crudFactor that creates an object (app) with methods for performing asynchronous HTTP requests.

Installation

To install the package, use the following npm command:

npm i crudfactor

const crudFactor = require('crud-factor');

const app = crudFactor();

// Perform GET request
const getData = async () => {
    const result = await app.get('https://api.example.com/data');
    console.log(result);
};

// Perform POST request
const postData = async () => {
    const data = { key: 'value' };
    const result = await app.post('https://api.example.com/post', data);
    console.log(result);
};

// Example usage
getData();
postData();


##Methods
get(url)
Perform an asynchronous HTTP GET request to the specified URL.

##Parameters:

url (String): The URL to send the GET request to.

##Returns:

A Promise that resolves to the parsed JSON data from the response.
post(url, data)
Perform an asynchronous HTTP POST request to the specified URL with the provided data.

##Parameters:

url (String): The URL to send the POST request to.
data (Object): The data to be sent in the request body.
Returns:

A Promise that resolves to the parsed JSON data from the response.
1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago