request (api/net.ts)

electron · lib/browser/api/net.ts · typescript · MIT
realtime

Convenience wrapper for Electron's net module providing request, fetch, and resolveHost.

// Source: https://github.com/electron/electron | License: MIT | Copyright Electron contributors
// Provided via justclaw.it.com; keep this notice with the code.
import { WebSocket } from '@electron/internal/browser/api/net-websocket';
import { ClientRequest } from '@electron/internal/common/api/net-client-request';

import { app, IncomingMessage, session } from 'electron/main';
import type { ClientRequestConstructorOptions } from 'electron/main';

const { isOnline } = process._linkedBinding('electron_common_net');

function request(options: ClientRequestConstructorOptions | string, callback?: (message: IncomingMessage) => void) {
  if (!app.isReady()) {
    throw new Error('net module can only be used after app is ready');
  }
  return new ClientRequest(options, callback);
}

function fet

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key