Skip to content

Commit

Permalink
Set default responseType to json
Browse files Browse the repository at this point in the history
  • Loading branch information
SamVerschueren committed Jul 24, 2020
1 parent 19d38e7 commit 80a792f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
14 changes: 4 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ import got4aws from 'got4aws';
const got = got4aws();

(async () => {
const {body} = await got.get('https://12abc34.execute-api.us-east-1.amazonaws.com/v0', {
responseType: 'json'
});
const {body} = await got.get('https://12abc34.execute-api.us-east-1.amazonaws.com/v0');

console.log(body);
//=> {status: 'ok'}
Expand All @@ -64,9 +62,7 @@ const got = got4aws({
});

(async () => {
const {body} = await got.get('https://12abc34.execute-api.us-east-1.amazonaws.com/v0', {
responseType: 'json'
});
const {body} = await got.get('https://12abc34.execute-api.us-east-1.amazonaws.com/v0');

console.log(body);
//=> {status: 'ok'}
Expand All @@ -85,9 +81,7 @@ const got = got4aws({
});

(async () => {
const {body} = await got.get('https://api.unicorn.com/v0', {
responseType: 'json'
});
const {body} = await got.get('https://api.unicorn.com/v0');

console.log(body);
//=> {status: 'ok'}
Expand All @@ -99,7 +93,7 @@ const got = got4aws({

### got4aws(options?)

Returns a [`Got`](https://github.com/sindresorhus/got) instance.
Returns a [`Got`](https://github.com/sindresorhus/got) instance with a default `responseType` set to `json`.

#### options

Expand Down
1 change: 1 addition & 0 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const got4aws = (awsOptions: GotAWSOptions = {}) => {
const chain = new AWS.CredentialProviderChain(credentialProviders as any);

return got.extend({
responseType: 'json',
hooks: {
beforeRequest: [
async options => {
Expand Down

0 comments on commit 80a792f

Please sign in to comment.