feat(goja): implement fetch API and fix websocket concurrency
fix(goja): handle ignored error returns in fetch API docs: add fetch API type definitions to global-types
This commit is contained in:
18
global-types/globals.d.ts
vendored
18
global-types/globals.d.ts
vendored
@@ -161,6 +161,24 @@ declare global {
|
||||
|
||||
// @ts-ignore
|
||||
const console: Console;
|
||||
|
||||
// Fetch API 相关类型
|
||||
interface FetchResponse {
|
||||
ok: boolean;
|
||||
status: number;
|
||||
statusText: string;
|
||||
headers: Record<string, string>;
|
||||
text(): Promise<string>;
|
||||
json<T = any>(): Promise<T>;
|
||||
}
|
||||
|
||||
interface FetchOptions {
|
||||
method?: string;
|
||||
headers?: Record<string, string>;
|
||||
body?: string;
|
||||
}
|
||||
|
||||
function fetch(url: string, options?: FetchOptions): Promise<FetchResponse>;
|
||||
}
|
||||
|
||||
export {};
|
||||
Reference in New Issue
Block a user