# @types/rails__request.js

> TypeScript definitions for @rails/request.js

Latest version **0.0.1** (published 2025-08-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/rails__request.js
pnpm add @types/rails__request.js
yarn add @types/rails__request.js
bun add @types/rails__request.js
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; popular repo; extremely popular.

Warnings: low downloads; no esm support; pre 1.0.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2025-08-10 |
| First published | 2024-01-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51342 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/rails__request.js
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/rails__request.js
- npm.io page: https://npm.io/package/@types/rails__request.js

## Recent versions

- 0.0.1 (latest) — 2025-08-10
- 0.0.0 (ts4.6) — 2024-01-30

## README

# Installation
> `npm install --save @types/rails__request.js`

# Summary
This package contains type definitions for @rails/request.js (https://github.com/rails/request.js).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/rails__request.js.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/rails__request.js/index.d.ts)
````ts
export class FetchRequest {
    constructor(method: string, url: string | URL, options?: Options);
    perform(): Promise<FetchResponse>;
    addHeader(key: string, value: string): void;
    sameHostname(): boolean;
    get fetchOptions(): RequestInit & { method: string; headers: HeadersInit };
    get headers(): HeadersInit;
    get csrfToken(): string | undefined;
    get contentType(): string | undefined;
    get accept(): string;
    get body(): BodyInit | Record<string, unknown> | null | undefined;
    get query(): string;
    get url(): string;
    get responseKind(): ResponseKind;
    get signal(): AbortSignal | null | undefined;
    get redirect(): RequestRedirect;
    get credentials(): RequestCredentials;
    get keepalive(): boolean;
    get additionalHeaders(): HeadersInit;
    get formattedBody(): string;
}

export type ResponseKind = "html" | "turbo-stream" | "json" | "script";

export interface Options {
    body?: BodyInit | Record<string, unknown> | null;
    contentType?: string;
    headers?: HeadersInit;
    credentials?: RequestCredentials;
    query?: Record<string, unknown> | FormData | URLSearchParams;
    responseKind?: ResponseKind;
    signal?: AbortSignal | null;
    redirect?: RequestRedirect;
    keepalive?: boolean;
}

export class FetchResponse {
    get statusCode(): number;
    get redirected(): boolean;
    get ok(): boolean;
    get unauthenticated(): boolean;
    get unprocessableEntity(): boolean;
    get authenticationURL(): string | null;
    get contentType(): string;
    get headers(): Headers;
    get html(): Promise<string>;
    get json(): Promise<any>;
    get text(): Promise<string>;
    get isTurboStream(): boolean;
    get isScript(): boolean;
    renderTurboStream(): Promise<void>;
    activeScript(): Promise<void>;
}

export class RequestInterceptor {
    static register(interceptor: (request: FetchRequest) => void | Promise<void>): void;
    static get(): (request: FetchRequest) => void | Promise<void>;
    static reset(): void;
}

export function get(url: string | URL, options?: Options): Promise<FetchResponse>;
export function post(url: string | URL, options?: Options): Promise<FetchResponse>;
export function put(url: string | URL, options?: Options): Promise<FetchResponse>;
export function patch(url: string | URL, options?: Options): Promise<FetchResponse>;
export function destroy(url: string | URL, options?: Options): Promise<FetchResponse>;

````

### Additional Details
 * Last updated: Sun, 10 Aug 2025 20:02:29 GMT
 * Dependencies: none

# Credits
These definitions were written by [Alexander Gitter](https://github.com/alexandergitter).

---
_Source: https://npm.io/package/@types/rails__request.js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
