@types/rails__request.js
TypeScript icon, indicating that this package has built-in type declarations

0.0.0 • Public • Published

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

export class FetchRequest {
    constructor(method: string, url: string, options?: Options);
    addHeader(key: string, value: string): void;
    perform(): Promise<FetchResponse>;
}

export interface Options {
    body?: BodyInit | Record<any, any>;
    contentType?: string;
    headers?: HeadersInit;
    credentials?: RequestCredentials;
    query?: Record<any, any> | FormData | URLSearchParams;
    responseKind?: "html" | "turbo-stream" | "json";
}

export class FetchResponse {
    get statusCode(): number;
    get redirected(): boolean;
    get ok(): boolean;
    get contentType(): string;
    get headers(): Headers;
    get html(): Promise<string>;
    get json(): Promise<any>;
    get text(): Promise<string>;
}

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

export function get(url: string, options?: Options): Promise<FetchResponse>;
export function post(url: string, options?: Options): Promise<FetchResponse>;
export function put(url: string, options?: Options): Promise<FetchResponse>;
export function patch(url: string, options?: Options): Promise<FetchResponse>;
export function destroy(url: string, options?: Options): Promise<FetchResponse>;

Additional Details

  • Last updated: Tue, 30 Jan 2024 06:35:26 GMT
  • Dependencies: none

Credits

These definitions were written by Alexander Gitter.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/rails__request.js

Weekly Downloads

1,212

Version

0.0.0

License

MIT

Unpacked Size

5.17 kB

Total Files

5

Last publish

Collaborators

  • types