From 832064634bdae63ed4fadd9019c6d5a8a3c225a1 Mon Sep 17 00:00:00 2001 From: Yongtae Date: Sun, 16 Jul 2023 18:22:31 +0900 Subject: [PATCH] Refactor API request to include Content-Type header --- .../ui/src/views/chatflows/APICodeDialog.js | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/packages/ui/src/views/chatflows/APICodeDialog.js b/packages/ui/src/views/chatflows/APICodeDialog.js index 5e32c1d4..9a036948 100644 --- a/packages/ui/src/views/chatflows/APICodeDialog.js +++ b/packages/ui/src/views/chatflows/APICodeDialog.js @@ -190,7 +190,10 @@ output = query({ "${baseURL}/api/v1/prediction/${dialogProps.chatflowid}", { method: "POST", - body: data + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify(data) } ); const result = await response.json(); @@ -229,9 +232,12 @@ output = query({ const response = await fetch( "${baseURL}/api/v1/prediction/${dialogProps.chatflowid}", { - headers: { Authorization: "Bearer ${selectedApiKey?.apiKey}" }, + headers: { + Authorization: "Bearer ${selectedApiKey?.apiKey}", + "Content-Type": "application/json" + }, method: "POST", - body: data + body: JSON.stringify(data) } ); const result = await response.json(); @@ -303,7 +309,10 @@ async function query(formData) { "${baseURL}/api/v1/prediction/${dialogProps.chatflowid}", { method: "POST", - body: formData + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify(formData) } ); const result = await response.json(); @@ -347,9 +356,12 @@ async function query(formData) { const response = await fetch( "${baseURL}/api/v1/prediction/${dialogProps.chatflowid}", { - headers: { Authorization: "Bearer ${selectedApiKey?.apiKey}" }, + headers: { + Authorization: "Bearer ${selectedApiKey?.apiKey}", + "Content-Type": "application/json" + }, method: "POST", - body: formData + body: JSON.stringify(formData) } ); const result = await response.json(); @@ -392,7 +404,10 @@ output = query({ "${baseURL}/api/v1/prediction/${dialogProps.chatflowid}", { method: "POST", - body: data + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify(data) } ); const result = await response.json(); @@ -439,9 +454,12 @@ output = query({ const response = await fetch( "${baseURL}/api/v1/prediction/${dialogProps.chatflowid}", { - headers: { Authorization: "Bearer ${selectedApiKey?.apiKey}" }, + headers: { + Authorization: "Bearer ${selectedApiKey?.apiKey}", + "Content-Type": "application/json" + }, method: "POST", - body: data + body: JSON.stringify(data) } ); const result = await response.json();