Skip to content

Commit aaeadee

Browse files
Fix request typo and redeclare block-scoped variable 'response' (#1329)
1 parent b894053 commit aaeadee

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/typescript.asciidoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ definitions for every exposed API.
77
NOTE: If you are using TypeScript you will be required to use _snake_case_ style
88
to define the API parameters instead of _camelCase_.
99

10-
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.
10+
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.
1111

1212
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.
1313

@@ -108,7 +108,7 @@ interface Source {
108108
async function run () {
109109
// All of the examples below are valid code, by default,
110110
// the request body will be `RequestBody` and response will be `Record<string, any>`.
111-
const response = await client.search({
111+
let response = await client.search({
112112
index: 'test',
113113
body: {
114114
query: {
@@ -120,7 +120,7 @@ async function run () {
120120
console.log(response.body)
121121
122122
// The first generic is the response body
123-
const response = await client.search<SearchResponse<Source>>({
123+
response = await client.search<SearchResponse<Source>>({
124124
index: 'test',
125125
// Here the body must follow the `RequestBody` interface
126126
body: {
@@ -132,7 +132,7 @@ async function run () {
132132
// body here is `SearchResponse<Source>`
133133
console.log(response.body)
134134
135-
const response = await client.search<SearchResponse<Source>, SearchBody>({
135+
response = await client.search<SearchResponse<Source>, SearchBody>({
136136
index: 'test',
137137
// Here the body must follow the `SearchBody` interface
138138
body: {

0 commit comments

Comments
 (0)