From 20c838e6ee505ffb2a10a7d64e4157b306305841 Mon Sep 17 00:00:00 2001 From: DebugIsFalse <511418503@qq.com> Date: Thu, 16 May 2024 10:46:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BB=B6=E7=94=A8=E7=B3=BB=E7=BB=9Ffetc?= =?UTF-8?q?h=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composables/useFetchRequest.js | 11 +++-------- pages/index.vue | 4 ++-- pages/search/[id].vue | 4 +--- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/composables/useFetchRequest.js b/composables/useFetchRequest.js index d269fb7..5d87309 100644 --- a/composables/useFetchRequest.js +++ b/composables/useFetchRequest.js @@ -13,14 +13,9 @@ const useFetchRequest = (baseUrl) => { fetchConfig['Content-Type'] = 'application/json'; } fetchConfig = Object.assign(config, fetchConfig); - return window.fetch(url, fetchConfig).then(async (response) => { - let result = await response.text() - try { - result = JSON.parse(result) - } catch(error) { - console.log(error) - } - return result; + return $fetch(url, fetchConfig).then(async (response) => { + console.log(`response:`, response) + return response; }).finally(() => { loading.value = false }) diff --git a/pages/index.vue b/pages/index.vue index 7138d37..2ae0f07 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -24,8 +24,8 @@