https://github.com/magicdawn/superagent-charset
add charset support for node's superagent
https://github.com/magicdawn/superagent-charset
Last synced: 11 months ago
JSON representation
add charset support for node's superagent
- Host: GitHub
- URL: https://github.com/magicdawn/superagent-charset
- Owner: magicdawn
- Created: 2015-01-15T15:40:13.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2021-10-18T14:51:49.000Z (over 4 years ago)
- Last Synced: 2024-12-10T02:10:37.053Z (over 1 year ago)
- Language: JavaScript
- Size: 37.1 KB
- Stars: 84
- Watchers: 8
- Forks: 12
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# superagent-charset
> add charset support for node's superagent
[](https://travis-ci.org/magicdawn/superagent-charset)
[](https://codecov.io/gh/magicdawn/superagent-charset)
[](https://www.npmjs.com/package/superagent-charset)
[](https://www.npmjs.com/package/superagent-charset)
[](http://magicdawn.mit-license.org)
[](https://greenkeeper.io/)
## Install
```js
$ npm i superagent-charset --save
```
## API
### install
```js
const request = require('superagent')
require('superagent-charset')(request)
```
this will add `request.Request.prototype.charset`
### charset
`.charset(encoding)` , will passed to [iconv-lite](https://github.com/ashtuchkin/iconv-lite)
```js
const should = require('should')
const request = require('superagent')
require('superagent-charset')(request) // install charset
describe('Basic Test', function() {
it('it works', function(done) {
request.get('http://www.sohu.com/')
.charset('gbk')
.end((err, res) => {
res.text.should.match(/搜狐/)
done(err)
})
})
})
```
## License
the MIT License, http://magicdawn.mit-license.org