1- import { fetch , Body } from "@tauri-apps/api/http"
1+ import { fetch , Body , ResponseType } from "@tauri-apps/api/http"
22import type { FetchOptions } from "@tauri-apps/api/http"
33
44interface RequestHeaders {
@@ -53,17 +53,18 @@ export class RocoRequest {
5353 this . $Option = { ...this . $Option , timeout }
5454 }
5555
56- async get ( path : string , params ?: any ) {
56+ async get < T > ( path : string , params ?: any ) {
5757 let reqUrl = this . $uri + path
5858 // Request Interception
5959 this . $interceptors . request ( )
6060 console . log ( "HTTP ST GET - " , reqUrl )
6161 // Request
62- const response = await fetch ( reqUrl , {
62+ const response = await fetch < T > ( reqUrl , {
6363 ...this . $Option ,
6464 method : "GET" ,
6565 headers : this . $headers ,
6666 query : { ...params } ,
67+ responseType : ResponseType . JSON ,
6768 } )
6869 console . log ( "HTTP RC GET - " , response )
6970
@@ -73,17 +74,18 @@ export class RocoRequest {
7374 return response
7475 }
7576
76- async post ( path : string , params : { } = { } ) {
77+ async post < T > ( path : string , params = { } ) {
7778 let reqUrl = this . $uri + path
7879 // Request Interception
7980 this . $interceptors . request ( )
8081 console . log ( "HTTP ST POST - " , reqUrl )
8182 // Request
82- const response = await fetch ( reqUrl , {
83+ const response = await fetch < T > ( reqUrl , {
8384 ...this . $Option ,
8485 method : "POST" ,
8586 headers : this . $headers ,
8687 body : Body . json ( { ...params } ) ,
88+ responseType : ResponseType . JSON ,
8789 } )
8890 console . log ( "HTTP RC POST - " , response )
8991
0 commit comments