UNPKG

@tableau/taco-toolkit

Version:
30 lines (29 loc) 1.14 kB
import { SuperAgentRequest } from 'superagent'; import { HTTPMethod } from '../types/http'; export interface RequestOptions { /** * Request headers. An object with key-value pair. * * For a `undefined` value, the corresponding header will not be added to the request. * For a non-string value, it will be serialized before being added as a header. */ headers?: Record<string, unknown>; /** * Query params. An object with key-value pair. * * The object will be serialized as query string and appended to the url. */ query?: Record<string, unknown>; } export interface RequestConfig extends RequestOptions { method: HTTPMethod; body?: string | object; } export declare function request(url: string, requestConfig: RequestConfig): SuperAgentRequest; /** * Normalize header object which has unknown type values. * * When a header value is not string type, the function converts it into string. * The function also filter out the entries with null or undefined value. */ export declare function normalizeHeaders(obj: Record<string, unknown>): Record<string, string>;