Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eldoy/sadope
Very easy to use NodeJS HTTP client
https://github.com/eldoy/sadope
Last synced: 6 days ago
JSON representation
Very easy to use NodeJS HTTP client
- Host: GitHub
- URL: https://github.com/eldoy/sadope
- Owner: eldoy
- Created: 2022-05-27T03:03:51.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-01-29T15:11:31.000Z (almost 2 years ago)
- Last Synced: 2024-10-12T22:44:14.745Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 49.8 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sadope
Very easy to use NodeJS HTTP client.
Predictable API. Does not throw error on non-200 response.
### Install
```
npm i sadope
```### Usage
```js
const request = require('sadope')// Default options
const options = {
method = 'get',
params = '',
query = '',
fields = {},
use = [],
auth = '',
headers = {},
type = '',
accept = ''
}
const url = 'https://api.example.com'
const response = await request(url, options)
{
code: 200,
data: {},
text: '',
length: 13,
type: 'text/html',
date: 2022-12-23T13:25:10.000Z,
connection: 'close',
ok: true
}
```On error the response includes an `error` object like this:
```js
{
code: 0,
data: {},
text: '',
length: 0,
type: '',
date: 2023-01-29T15:09:30.000Z,
connection: '',
headers: {},
ok: false,
error: {
errno: -61,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 54364,
message: 'connect ECONNREFUSED 127.0.0.1:54364'
}
}
```ISC Licensed. Enjoy!