Skip to content
This repository was archived by the owner on Aug 20, 2020. It is now read-only.

docs: Adds example to review request body for troubleshooting. #30

Merged
merged 1 commit into from
Oct 29, 2017
Merged
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
30 changes: 30 additions & 0 deletions TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
If you have a non-library SendGrid issue, please contact our [support team](https://support.sendgrid.com).

If you can't find a solution below, please open an [issue](https://github.com/sendgrid/nodejs-http-client/issues).

## Table of Contents
* [Viewing the Request Body](#request-body)

<a name="request-body"></a>
## Viewing the Request Body

When debugging or testing, it may be useful to examine the raw request body to compare against the [documented format](https://sendgrid.com/docs/API_Reference/api_v3.html).

You can do this with something like:
```javascript
var requestPost = client.emptyRequest()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be up for using one of the examples here to show how this pattern can be used to print the request body?

Copy link
Contributor Author

@mukulmishra18 mukulmishra18 Oct 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I did not get it properly. I think I already added how to log request body here, before sending the POST request. Should I have to log requestPost.body here also?

requestPost.method = 'POST'
requestPost.path = '/v3/api_keys'
requestPost.body = { data: 'some test data' }
requestPost.headers['X-Test'] = 'test'

// Log request body before sending POST request.
console.log(requestPost.body)

client.API(requestPost, (response) => {
// Log the response.
console.log(response.statusCode)
console.log(response.body)
console.log(response.headers)
})
```