mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-06-29 03:47:33 +00:00
add http query
This commit is contained in:
parent
3113c67112
commit
c7a087e715
@ -41,16 +41,18 @@ export async function httpQuery({
|
|||||||
method = "GET",
|
method = "GET",
|
||||||
json,
|
json,
|
||||||
headers = {},
|
headers = {},
|
||||||
|
basePath = `/graphql`,
|
||||||
}: {
|
}: {
|
||||||
path?: string;
|
path?: string;
|
||||||
method: string;
|
method: string;
|
||||||
json: unknown;
|
json: unknown;
|
||||||
headers: Recordable;
|
headers: Recordable;
|
||||||
|
basePath?: string;
|
||||||
}) {
|
}) {
|
||||||
const timeoutId = setTimeout(() => {
|
const timeoutId = setTimeout(() => {
|
||||||
abortRequestsAndUpdate();
|
abortRequestsAndUpdate();
|
||||||
}, Timeout);
|
}, Timeout);
|
||||||
const url = `${BasePath}${path}`;
|
const url = `${basePath || BasePath}${path}`;
|
||||||
const response: Response = await fetch(url, {
|
const response: Response = await fetch(url, {
|
||||||
method,
|
method,
|
||||||
headers: {
|
headers: {
|
||||||
|
37
src/graphql/http.ts
Normal file
37
src/graphql/http.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import { httpQuery } from "./base";
|
||||||
|
|
||||||
|
export default async function fetchQuery({
|
||||||
|
headers,
|
||||||
|
method,
|
||||||
|
json,
|
||||||
|
}: {
|
||||||
|
method: string;
|
||||||
|
json: unknown;
|
||||||
|
headers: Recordable;
|
||||||
|
}) {
|
||||||
|
const response = await httpQuery({
|
||||||
|
method,
|
||||||
|
json,
|
||||||
|
headers,
|
||||||
|
});
|
||||||
|
if (response.errors) {
|
||||||
|
response.errors = response.errors.map((e: { message: string }) => e.message).join(" ");
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user