浏览代码

remove the params option from apiRequestService.request

Olivier Massot 2 年之前
父节点
当前提交
fffa4beb65
共有 1 个文件被更改,包括 6 次插入16 次删除
  1. 6 16
      services/data/apiRequestService.ts

+ 6 - 16
services/data/apiRequestService.ts

@@ -5,11 +5,10 @@
  */
 import {AssociativeArray} from "~/types/data";
 import {HTTP_METHOD} from "~/types/enum/data";
-import {$Fetch, FetchOptions} from "ohmyfetch";
+import {FetchOptions} from "ofetch";
+import {$Fetch} from "nitropack";
 
 class ApiRequestService {
-    // TODO: fusionner les paramètres `query` et `params` des méthodes, puisque l'un est un alias de l'autre
-    //       dans ohmyfetch : https://github.com/unjs/ofetch#%EF%B8%8F-adding-query-search-params
     private readonly fetch: $Fetch
 
     public constructor(
@@ -28,7 +27,7 @@ class ApiRequestService {
         url: string,
         query: AssociativeArray | null = null
     ) {
-        return await this.request(HTTP_METHOD.GET, url, null, null, query)
+        return await this.request(HTTP_METHOD.GET, url, null, query)
     }
 
     /**
@@ -36,16 +35,14 @@ class ApiRequestService {
      *
      * @param url
      * @param body
-     * @param params
      * @param query
      */
     public async post(
         url: string,
         body: string | null = null,
-        params: AssociativeArray | null = null,
         query: AssociativeArray | null = null
     ) {
-        return await this.request(HTTP_METHOD.POST, url, body, params, query)
+        return await this.request(HTTP_METHOD.POST, url, body, query)
     }
 
     /**
@@ -53,16 +50,14 @@ class ApiRequestService {
      *
      * @param url
      * @param body
-     * @param params
      * @param query
      */
     public async put(
         url: string,
         body: string | null = null,
-        params: AssociativeArray | null = null,
         query: AssociativeArray | null = null
     ) {
-        return await this.request(HTTP_METHOD.PUT, url, body, params, query)
+        return await this.request(HTTP_METHOD.PUT, url, body, query)
     }
 
     /**
@@ -75,7 +70,7 @@ class ApiRequestService {
         url: string,
         query: AssociativeArray | null = null
     ) {
-        return await this.request(HTTP_METHOD.DELETE, url, null, null, query)
+        return await this.request(HTTP_METHOD.DELETE, url, null, query)
     }
 
     /**
@@ -84,7 +79,6 @@ class ApiRequestService {
      * @param method
      * @param url
      * @param body
-     * @param params
      * @param query
      * @protected
      */
@@ -92,13 +86,9 @@ class ApiRequestService {
         method: HTTP_METHOD,
         url: string,
         body: string | null = null,
-        params: AssociativeArray | null = null,
         query: AssociativeArray | null = null
     ): Promise<Response> {
         const config: FetchOptions = { method }
-        if (params) {
-            config.params = params
-        }
         if (query) {
             config.query = query
         }