Skip to content

Commit c19f28f

Browse files
committed
fix post search endpoint default parameters bug
1 parent 832405d commit c19f28f

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

core/src/Endpoint/Search/PostSearchEndpoint.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,19 @@ class PostSearchEndpoint {
3434
const url = this.fetchHelper.buildUrl('/search');
3535
this.logger.debug(`Executing HTTP POST request against URL: ${url}`);
3636

37-
const response = await fetch(
38-
url,
39-
this.fetchHelper.getDefaultPostOptions(
40-
JSON.stringify({
41-
steps: steps,
42-
parameters: parameters,
43-
debug: debug,
44-
}),
45-
),
46-
).catch((error) => this.fetchHelper.rethrowErrorAsNetworkError(error));
37+
const payload: Record<string, unknown> = {
38+
steps,
39+
};
40+
if (parameters !== null) {
41+
payload.parameters = parameters;
42+
}
43+
if (debug) {
44+
payload.debug = true;
45+
}
46+
47+
const response = await fetch(url, this.fetchHelper.getDefaultPostOptions(JSON.stringify(payload))).catch(
48+
(error) => this.fetchHelper.rethrowErrorAsNetworkError(error),
49+
);
4750

4851
const rawData = await this.fetchHelper.parseJsonResponse(response);
4952

0 commit comments

Comments
 (0)