From b266122005599e5d315f4332d8760e3a529b17e3 Mon Sep 17 00:00:00 2001 From: prasenjit singh Date: Tue, 21 Jan 2025 19:21:10 +0530 Subject: [PATCH] Fix in makeHttpCall.js When we make a GET call using this makeHttpCall Axios wrapper, it's throwing a 400 Bad Request error. I have observed this issue while dealing with conversation history and using the sdk.getMessages method of the Botkit SDK. This method internally resolves to a GET call to the conversation API of the Kore.ai platform. --- makeHttpCall.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/makeHttpCall.js b/makeHttpCall.js index 04f34315..c4311ff3 100644 --- a/makeHttpCall.js +++ b/makeHttpCall.js @@ -12,14 +12,13 @@ const axios = require('axios'); * @throws {Error} If an error occurs during the request. */ -async function makeHttpCall(method, url, data = null, headers = {}) { +async function makeHttpCall(method, url, data = undefined, headers = {}) { try { - const response = await axios({ - method, - url, - data, - headers, - }); + const options = { + url, method, headers, data + } + + const response = await axios(options); return response; } catch (error) { @@ -27,7 +26,6 @@ async function makeHttpCall(method, url, data = null, headers = {}) { } } - module.exports = { makeHttpCall -} \ No newline at end of file +}