Skip to content

Optionally show response payload with debug command line parameter #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ $ apig-test \
--additional-params='{}' \
--access-token-header='cognito-access-token' \
--body='{}'
--debug
```

If you have it locally installed:
Expand Down Expand Up @@ -70,7 +71,7 @@ This command takes the following options:

- `api-gateway-region`
The API Gateway region. Defaults to `us-east-1`.

- `api-key`
The API key if required by the method. Defaults to none.

Expand All @@ -92,6 +93,9 @@ This command takes the following options:
- `body`
The request body as a JSON string. Defaults to `'{}'`.

- `debug`
Additional debug output for response payload and errors.

For additional documentation on the format for `params` and `additional-params`; refer to the generic [API Gateway Client][apiGClient] docs.

### Local Development
Expand Down
15 changes: 14 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ var argv = require("yargs")
.option("access-token-header", {
describe: "Header to use to pass access token with request"
})
.option("debug",{
describe: "Additional debug output for response and errors",
default: false
})
.help("h")
.alias("d", "debug")
.alias("h", "help")
.alias("v", "version")
.version(packageJson.version)
Expand Down Expand Up @@ -180,6 +185,10 @@ function makeRequest(userTokens) {
status: result.status,
statusText: result.statusText,
data: result.data
},{
showHidden:argv.debug,
depth:argv.debug ? null : 2,
colors:argv.debug
});
})
.catch(function(result) {
Expand All @@ -188,7 +197,11 @@ function makeRequest(userTokens) {
status: result.response.status,
statusText: result.response.statusText,
data: result.response.data
});
},{
showHidden:argv.debug,
depth:argv.debug ? null : 2,
colors:argv.debug
});
} else {
console.log(result.message);
}
Expand Down