change successfulFetch return type

This commit is contained in:
CounterFire2023 2024-01-18 11:45:26 +08:00
parent 2a61704a0d
commit 1bbbd4f389
5 changed files with 7 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
import fetch, { RequestInit, Response } from 'node-fetch'; import { RequestInit, Response } from 'node-fetch';
/** /**
* Execute fetch and verify that the response was successful. * Execute fetch and verify that the response was successful.
@ -7,7 +7,7 @@ import fetch, { RequestInit, Response } from 'node-fetch';
* @param options - Fetch options. * @param options - Fetch options.
* @returns The fetch response. * @returns The fetch response.
*/ */
declare function successfulFetch(request: string, options?: RequestInit): Promise<fetch.Response>; declare function successfulFetch(request: string, options?: RequestInit): Promise<any>;
/** /**
* Execute fetch and return object response. * Execute fetch and return object response.
* *

View File

@ -1,4 +1,4 @@
import fetch, { RequestInit, Response } from 'node-fetch'; import { RequestInit, Response } from 'node-fetch';
/** /**
* Execute fetch and verify that the response was successful. * Execute fetch and verify that the response was successful.
@ -7,7 +7,7 @@ import fetch, { RequestInit, Response } from 'node-fetch';
* @param options - Fetch options. * @param options - Fetch options.
* @returns The fetch response. * @returns The fetch response.
*/ */
declare function successfulFetch(request: string, options?: RequestInit): Promise<fetch.Response>; declare function successfulFetch(request: string, options?: RequestInit): Promise<any>;
/** /**
* Execute fetch and return object response. * Execute fetch and return object response.
* *

File diff suppressed because one or more lines are too long

View File

@ -12,7 +12,7 @@ const hexRe = /^[0-9A-Fa-f]+$/gu
* @param options - Fetch options. * @param options - Fetch options.
* @returns The fetch response. * @returns The fetch response.
*/ */
export async function successfulFetch(request: string, options?: RequestInit) { export async function successfulFetch(request: string, options?: RequestInit): Promise<any> {
const response = await fetch(request, options) const response = await fetch(request, options)
if (!response.ok) { if (!response.ok) {
throw new Error(`Fetch failed with status '${response.status}' for request '${request}'`) throw new Error(`Fetch failed with status '${response.status}' for request '${request}'`)