https://github.com/52cik/tiny-curl
A tiny "CURL" tool with nodejs
https://github.com/52cik/tiny-curl
Last synced: 2 months ago
JSON representation
A tiny "CURL" tool with nodejs
- Host: GitHub
- URL: https://github.com/52cik/tiny-curl
- Owner: 52cik
- License: mit
- Created: 2016-10-20T14:39:39.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-20T10:04:44.000Z (over 7 years ago)
- Last Synced: 2025-03-18T04:35:52.100Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tiny-curl
> A tiny CURL wrapper for node
## Install
```sh
$ npm install tiny-curl
```## Usage
```js
const curl = require('tiny-curl');
const url = 'https://api.github.com/users/52cik';curl(url, { json: true }).then(({ body }) => {
console.log(body.name); // 楼教主
});// async/await
(async () => {
const { body } = await curl(url, { json: true });
console.log(body.name); // 楼教主
})();```
## API
#### curl(url, [options])
##### url
Type: `string`
##### options
Type: `Object`
Any of the `http.request` options.
###### body
Type: `string` `Object`
###### encoding
Type: `string` `null`
Default: `'utf8'`###### json
Type: `boolean`
Default: `false`###### query
Type: `string` `Object`
#### curl.get(url, [options])
#### curl.post(url, [options])
#### curl.put(url, [options])
#### curl.patch(url, [options])
#### curl.head(url, [options])
#### curl.delete(url, [options])
Sets `options.method` to the method name and makes a request.