Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chemzqm/got
simple request utility
https://github.com/chemzqm/got
Last synced: about 1 month ago
JSON representation
simple request utility
- Host: GitHub
- URL: https://github.com/chemzqm/got
- Owner: chemzqm
- Created: 2014-07-14T11:08:46.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-10-31T15:01:50.000Z (about 9 years ago)
- Last Synced: 2024-10-29T10:08:22.109Z (2 months ago)
- Language: JavaScript
- Size: 137 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# got
simple xhr utility.
no event supported.
no binary supported.
## Installation
Install with [component(1)](http://component.io):
$ component install chemzqm/got
## API
### got(url, [option], callback)
* `url` is the url to request
* optional `option` could contains:
* `method` get, post, delete, head, `get` by default
* `query` query string or query object serialized by `encodeURIComponent`
* `body` request body send to the server side, by default encoded by `encodeURIComponent`
* `type` request body type, could be `json` and `form`, `form` by default
* `headers` headers to be sent
* `timeout` request timeout in millisecond, `10s` by default* callback function takes two arguments
* `err` is error object could be `network error`, `crossDomain error` or `timeout error`.
* `res` is the response object has `res.text` for plain response text, `res.status` for status code, `res.body` for parsed response body if response content type is json, `res.ok` is true if `status==2xx`## License
MIT