// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 interface IRequestParams { url: string; body?: object; method?: 'GET' | 'POST' | 'PUT' | 'DELETE'; queryParams?: Record; headers?: Record; } const request = async ({ url = '', method = 'GET', body, queryParams = {}, headers = { 'content-type': 'application/json', }, }: IRequestParams): Promise => { const response = await fetch(`${url}?${new URLSearchParams(queryParams).toString()}`, { method, body: body ? JSON.stringify(body) : undefined, headers, }); const responseText = await response.text(); if (!!responseText) return JSON.parse(responseText); return undefined as unknown as T; }; export default request;