Skip to content
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

Improve HttpRequests #1741

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9f41065
Improve HttpRequests
flevi29 Oct 9, 2024
a32ed2d
Convert props to private, refactor, adapt tests
flevi29 Oct 9, 2024
118534d
Fix type issue
flevi29 Oct 9, 2024
942e889
Improve timeout, refactor
flevi29 Oct 10, 2024
455d8c3
Misc
flevi29 Oct 10, 2024
d1b442b
Fix browser env test
flevi29 Oct 10, 2024
c044319
Fix Node.js 18 fetch signal issue
flevi29 Oct 10, 2024
e6236f6
Add extra RequestInit for search
flevi29 Oct 11, 2024
4a49790
Refactor
flevi29 Oct 11, 2024
0e41c86
Fix type issues
flevi29 Oct 11, 2024
1949134
Fix some types
flevi29 Oct 11, 2024
ace3412
Make extraRequestInit function as it originally did
flevi29 Oct 11, 2024
3854e13
Remove unnecessary transformation
flevi29 Oct 11, 2024
d73d58d
Revert some type changes
flevi29 Oct 11, 2024
2d4849d
Optimize
flevi29 Oct 11, 2024
8825781
Merge branch 'main' into improve-http-request
flevi29 Oct 14, 2024
db9aa94
Merge with main branch
flevi29 Oct 30, 2024
432f338
Merge branch 'main' into improve-http-request
flevi29 Oct 31, 2024
d70f962
Merge branch 'main' into improve-http-request
flevi29 Nov 1, 2024
aa10d8c
Merge with main
flevi29 Dec 2, 2024
f81e7ca
Merge branch 'improve-http-request' of github.com:flevi29/meilisearch…
flevi29 Dec 6, 2024
f231e95
Merge branch 'main' into improve-http-request
flevi29 Dec 6, 2024
8f29bc2
Merge with main
flevi29 Dec 23, 2024
edff9a9
Merge branch 'main' into improve-http-request
flevi29 Dec 27, 2024
36c174f
Fix types
flevi29 Dec 27, 2024
a26cc1d
Merge branch 'main' into improve-http-request
flevi29 Jan 2, 2025
f0998be
Merge branch 'main' into improve-http-request
flevi29 Jan 3, 2025
f7b1e88
Merge with main
flevi29 Jan 8, 2025
a32c773
Fix type and style issues
flevi29 Jan 8, 2025
aaaaf3b
Test extra headers as well
flevi29 Jan 8, 2025
ed15092
Merge branch 'main' into improve-http-request
flevi29 Jan 8, 2025
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
19 changes: 9 additions & 10 deletions src/batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
BatchesResults,
BatchesResultsObject,
} from "./types.js";
import { HttpRequests, toQueryParams } from "./http-requests.js";
import { HttpRequests } from "./http-requests.js";

class Batch {
uid: BatchObject["uid"];
Expand Down Expand Up @@ -41,8 +41,9 @@ class BatchClient {
* @returns
*/
async getBatch(uid: number): Promise<Batch> {
const url = `batches/${uid}`;
const batch = await this.httpRequest.get<BatchObject>(url);
const batch = (await this.httpRequest.get({
relativeURL: `batches/${uid}`,
})) as BatchObject;
return new Batch(batch);
}

Expand All @@ -52,13 +53,11 @@ class BatchClient {
* @param parameters - Parameters to browse the batches
* @returns Promise containing all batches
*/
async getBatches(parameters: BatchesQuery = {}): Promise<BatchesResults> {
const url = `batches`;

const batches = await this.httpRequest.get<Promise<BatchesResultsObject>>(
url,
toQueryParams<BatchesQuery>(parameters),
);
async getBatches(batchesQuery?: BatchesQuery): Promise<BatchesResults> {
const batches = (await this.httpRequest.get({
relativeURL: "batches",
params: batchesQuery,
})) as BatchesResultsObject;

return {
...batches,
Expand Down
Loading
Loading