Skip to content

Fix request typo and redeclare block-scoped variable 'response' #1329

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

Merged
merged 1 commit into from
Oct 5, 2020
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
8 changes: 4 additions & 4 deletions docs/typescript.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ definitions for every exposed API.
NOTE: If you are using TypeScript you will be required to use _snake_case_ style
to define the API parameters instead of _camelCase_.

By default event API uses https://www.typescriptlang.org/docs/handbook/generics.html[generics] to specify the requets and response bodies and the `meta.context`. Currently we can't provide those definitions, but we are working to improve this situation.
By default event API uses https://www.typescriptlang.org/docs/handbook/generics.html[generics] to specify the requests and response bodies and the `meta.context`. Currently we can't provide those definitions, but we are working to improve this situation.

You can find a partial definition of the request types by importing `RequestParams`, which is used by default in the client and accepts a body (when needed) as a generic to provide a better specification.

Expand Down Expand Up @@ -108,7 +108,7 @@ interface Source {
async function run () {
// All of the examples below are valid code, by default,
// the request body will be `RequestBody` and response will be `Record<string, any>`.
const response = await client.search({
let response = await client.search({
index: 'test',
body: {
query: {
Expand All @@ -120,7 +120,7 @@ async function run () {
console.log(response.body)

// The first generic is the response body
const response = await client.search<SearchResponse<Source>>({
response = await client.search<SearchResponse<Source>>({
index: 'test',
// Here the body must follow the `RequestBody` interface
body: {
Expand All @@ -132,7 +132,7 @@ async function run () {
// body here is `SearchResponse<Source>`
console.log(response.body)

const response = await client.search<SearchResponse<Source>, SearchBody>({
response = await client.search<SearchResponse<Source>, SearchBody>({
index: 'test',
// Here the body must follow the `SearchBody` interface
body: {
Expand Down