simplerestapi
Version:
A simple and simplified request generator.
36 lines (23 loc) • 1.07 kB
Markdown
# simplerestapi
A simple and simplified request generator.
## API Reference
#### How to use
```JS
const {petitionType} = require("simplerestapi");
petitionType("API","method","data")
//Examples
const { petitionType, petitionTypeAuth } = require('simplerestapi');
// Example 1: Making a basic HTTP request
const apiUrl = 'https://api.example.com/data';
const requestData = { key: 'value' };
petitionType(apiUrl, 'GET', requestData);
// Example 2: Making an authenticated HTTP request
const authApiUrl = 'https://api.example.com/authenticated-data';
const authData = { username: 'exampleUser', password: 'secretPassword' };
const authToken = 'Bearer YOUR_ACCESS_TOKEN';
petitionTypeAuth(authApiUrl, 'POST', authData, authToken);
```
| Parameter | Type | Description |
| :-------- | :------- | :------------------------- |
| `petitionType` | `string` `string` `string` | Generates the API request |
| `petitionTypeAuth` | `string` `type` `string` `string` | Generates API request but with token access |