ソースを参照

[frontend] Switch to Axios in the SQL reference API service to support a custom base url in web components

Johan Ahlen 4 年 前
コミット
b51bd09d9d
1 ファイル変更7 行追加5 行削除
  1. 7 5
      desktop/core/src/desktop/js/sql/reference/apiUtils.ts

+ 7 - 5
desktop/core/src/desktop/js/sql/reference/apiUtils.ts

@@ -14,7 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-import { simplePostAsync } from 'api/apiUtils';
+import { post } from 'api/utils';
 import { AUTOCOMPLETE_API_PREFIX } from 'api/urls';
 import { UdfArgument, UdfDetails } from 'sql/reference/types';
 import { Connector } from 'config/types';
@@ -156,8 +156,10 @@ export const fetchUdfs = async (
   const data = createRequestData(connector, FUNCTIONS_OPERATION);
 
   try {
-    const response = await simplePostAsync(url, data, { silenceErrors: silenceErrors });
-    if (response && response.functions) {
+    const response = await post<{ functions?: ApiUdf[] }>(url, data, {
+      silenceErrors: silenceErrors
+    });
+    if (response?.functions) {
       return adaptApiFunctions(response.functions);
     }
   } catch (err) {}
@@ -174,8 +176,8 @@ export const fetchDescribe = async (
   const data = createRequestData(connector, FUNCTION_OPERATION);
 
   try {
-    const response = await simplePostAsync(url, data, { silenceErrors: silenceErrors });
-    if (response && response.function) {
+    const response = await post<{ function?: ApiUdf }>(url, data, { silenceErrors: silenceErrors });
+    if (response?.function) {
       return response.function;
     }
   } catch (err) {}