From 2fc39fc341771431078c20a95fa6b2affe5155c9 Mon Sep 17 00:00:00 2001 From: Kid <44045911+kidonng@users.noreply.github.com> Date: Wed, 17 Mar 2021 18:39:15 +0800 Subject: [PATCH] fix(api/http): correct types (#1360) * fix(api/http): correct types * Add changes * Update correct-http-api-types.md --- .changes/correct-http-api-types.md | 5 +++++ api/src/http.ts | 16 ++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 .changes/correct-http-api-types.md diff --git a/.changes/correct-http-api-types.md b/.changes/correct-http-api-types.md new file mode 100644 index 000000000..eac77e2c9 --- /dev/null +++ b/.changes/correct-http-api-types.md @@ -0,0 +1,5 @@ +--- +"tauri-api": patch +--- + +Align HTTP API types with the [documentation](https://tauri.studio/en/docs/api/js#http). diff --git a/api/src/http.ts b/api/src/http.ts index 5c65dfce7..a6ca6536f 100644 --- a/api/src/http.ts +++ b/api/src/http.ts @@ -1,7 +1,7 @@ import { invokeTauriCommand } from './helpers/tauri' export interface ClientOptions { - maxRedirections: boolean + maxRedirections: number connectTimeout: number } @@ -115,7 +115,7 @@ export class Client { * * @return promise resolving to the response */ - async get(url: string, options: RequestOptions): Promise> { + async get(url: string, options?: RequestOptions): Promise> { return this.request({ method: 'GET', url, @@ -134,8 +134,8 @@ export class Client { */ async post( url: string, - body: Body, - options: RequestOptions + body?: Body, + options?: RequestOptions ): Promise> { return this.request({ method: 'POST', @@ -156,8 +156,8 @@ export class Client { */ async put( url: string, - body: Body, - options: RequestOptions + body?: Body, + options?: RequestOptions ): Promise> { return this.request({ method: 'PUT', @@ -175,7 +175,7 @@ export class Client { * * @return promise resolving to the response */ - async patch(url: string, options: RequestOptions): Promise> { + async patch(url: string, options?: RequestOptions): Promise> { return this.request({ method: 'PATCH', url, @@ -191,7 +191,7 @@ export class Client { * * @return promise resolving to the response */ - async delete(url: string, options: RequestOptions): Promise> { + async delete(url: string, options?: RequestOptions): Promise> { return this.request({ method: 'DELETE', url,