@@ -90,7 +90,7 @@ type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
9090// - Chrome 76: "TypeError: Failed to fetch"
9191// - DOMException if request aborted
9292function request < T extends BodyInit > (
93- input : RequestInfo ,
93+ input : RequestInfo | URL ,
9494 headers : Headers ,
9595 init : Omit < Init , 'headers' > | undefined ,
9696 method : Method ,
@@ -142,7 +142,7 @@ function getJSONHeaders(init?: Init) {
142142/**
143143 * Performs a HTTP `GET` request.
144144 */
145- export function get ( input : RequestInfo , init ?: Init ) {
145+ export function get ( input : RequestInfo | URL , init ?: Init ) {
146146 return request ( input , getHeaders ( init ) , init , 'GET' ) ;
147147}
148148
@@ -151,7 +151,7 @@ export function get(input: RequestInfo, init?: Init) {
151151 *
152152 * @see {@link postJSON() }
153153 */
154- export function post < T extends BodyInit > ( input : RequestInfo , body ?: T , init ?: Init ) {
154+ export function post < T extends BodyInit > ( input : RequestInfo | URL , body ?: T , init ?: Init ) {
155155 return request ( input , getHeaders ( init ) , init , 'POST' , body ) ;
156156}
157157
@@ -166,7 +166,7 @@ export function post<T extends BodyInit>(input: RequestInfo, body?: T, init?: In
166166//
167167// Record<string, unknown> is compatible with "type" not with "interface": "Index signature is missing in type 'MyInterface'"
168168// Best alternative is object, why? https://stackoverflow.com/a/58143592
169- export function postJSON < T extends object > ( input : RequestInfo , body : T , init ?: Init ) {
169+ export function postJSON < T extends object > ( input : RequestInfo | URL , body : T , init ?: Init ) {
170170 return request ( input , getJSONHeaders ( init ) , init , 'POST' , JSON . stringify ( body ) ) ;
171171}
172172// No need to have postFormData() and friends: the browser already sets the proper request content type
@@ -177,7 +177,7 @@ export function postJSON<T extends object>(input: RequestInfo, body: T, init?: I
177177 *
178178 * @see {@link putJSON() }
179179 */
180- export function put < T extends BodyInit > ( input : RequestInfo , body ?: T , init ?: Init ) {
180+ export function put < T extends BodyInit > ( input : RequestInfo | URL , body ?: T , init ?: Init ) {
181181 return request ( input , getHeaders ( init ) , init , 'PUT' , body ) ;
182182}
183183
@@ -186,7 +186,7 @@ export function put<T extends BodyInit>(input: RequestInfo, body?: T, init?: Ini
186186 *
187187 * @see {@link put() }
188188 */
189- export function putJSON < T extends object > ( input : RequestInfo , body : T , init ?: Init ) {
189+ export function putJSON < T extends object > ( input : RequestInfo | URL , body : T , init ?: Init ) {
190190 return request ( input , getJSONHeaders ( init ) , init , 'PUT' , JSON . stringify ( body ) ) ;
191191}
192192
@@ -195,7 +195,7 @@ export function putJSON<T extends object>(input: RequestInfo, body: T, init?: In
195195 *
196196 * @see {@link patchJSON() }
197197 */
198- export function patch < T extends BodyInit > ( input : RequestInfo , body ?: T , init ?: Init ) {
198+ export function patch < T extends BodyInit > ( input : RequestInfo | URL , body ?: T , init ?: Init ) {
199199 return request ( input , getHeaders ( init ) , init , 'PATCH' , body ) ;
200200}
201201
@@ -204,14 +204,14 @@ export function patch<T extends BodyInit>(input: RequestInfo, body?: T, init?: I
204204 *
205205 * @see {@link patch() }
206206 */
207- export function patchJSON < T extends object > ( input : RequestInfo , body : T , init ?: Init ) {
207+ export function patchJSON < T extends object > ( input : RequestInfo | URL , body : T , init ?: Init ) {
208208 return request ( input , getJSONHeaders ( init ) , init , 'PATCH' , JSON . stringify ( body ) ) ;
209209}
210210
211211/**
212212 * Performs a HTTP `DELETE` request.
213213 */
214214// Cannot be named delete :-/
215- export function del ( input : RequestInfo , init ?: Init ) {
215+ export function del ( input : RequestInfo | URL , init ?: Init ) {
216216 return request ( input , getHeaders ( init ) , init , 'DELETE' ) ;
217217}
0 commit comments