From 651e7c31f1cd6b2acf47acb84f9dafdcfd26bda6 Mon Sep 17 00:00:00 2001 From: suhaotian Date: Thu, 18 Jul 2024 19:17:20 +1000 Subject: [PATCH] Update --- src/interceptors.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/interceptors.ts b/src/interceptors.ts index 71a052e..fb8a390 100644 --- a/src/interceptors.ts +++ b/src/interceptors.ts @@ -40,12 +40,10 @@ export default async function defaultRequestInterceptor(req: XiorInterceptorRequ contentType = req.headers[key]; } } - if (isUrlSearchParams) { - contentType = formUrl; - } else if (!contentType) { - contentType = isGet ? formUrl : jsonType; + if (!contentType || isUrlSearchParams) { + contentType = isGet || isUrlSearchParams ? formUrl : jsonType; + headers[contentTypeKey] = contentType; } - headers[contentTypeKey] = contentType; if (typeof data === 'object') { if (isGet && req.params) {