fix(api/http): correct types (#1360)

* fix(api/http): correct types

* Add changes

* Update correct-http-api-types.md
This commit is contained in:
Kid
2021-03-17 18:39:15 +08:00
committed by GitHub
parent 4ee044a3e6
commit 2fc39fc341
2 changed files with 13 additions and 8 deletions

View File

@@ -0,0 +1,5 @@
---
"tauri-api": patch
---
Align HTTP API types with the [documentation](https://tauri.studio/en/docs/api/js#http).

View File

@@ -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<T>(url: string, options: RequestOptions): Promise<Response<T>> {
async get<T>(url: string, options?: RequestOptions): Promise<Response<T>> {
return this.request({
method: 'GET',
url,
@@ -134,8 +134,8 @@ export class Client {
*/
async post<T>(
url: string,
body: Body,
options: RequestOptions
body?: Body,
options?: RequestOptions
): Promise<Response<T>> {
return this.request({
method: 'POST',
@@ -156,8 +156,8 @@ export class Client {
*/
async put<T>(
url: string,
body: Body,
options: RequestOptions
body?: Body,
options?: RequestOptions
): Promise<Response<T>> {
return this.request({
method: 'PUT',
@@ -175,7 +175,7 @@ export class Client {
*
* @return promise resolving to the response
*/
async patch<T>(url: string, options: RequestOptions): Promise<Response<T>> {
async patch<T>(url: string, options?: RequestOptions): Promise<Response<T>> {
return this.request({
method: 'PATCH',
url,
@@ -191,7 +191,7 @@ export class Client {
*
* @return promise resolving to the response
*/
async delete<T>(url: string, options: RequestOptions): Promise<Response<T>> {
async delete<T>(url: string, options?: RequestOptions): Promise<Response<T>> {
return this.request({
method: 'DELETE',
url,