import { makeRequest } from './make-request'; import { HttpRequest } from '../types/request'; import { HttpResponse } from '../types/response'; /** * A function that makes a HTTP request with the PUT method * @param url URL for the request * @param key secret key for the request * @param additionalHeaders any headers that are additional to contentType and x-api-key * @returns it returns a HTTP promise response */ export async function put({ url, key, body, additionalHeaders = {} }: HttpRequest, fetch: Function): Promise { const options = { method: 'PUT', headers: { 'Content-Type': 'application/json', 'X-api-key': key, ...additionalHeaders }, body: JSON.stringify(body) }; return makeRequest(url, options, fetch); }