most-request
TypeScript icon, indicating that this package has built-in type declarations

2.1.0 • Public • Published

most-request

Simple Most.js wrapper around superagent

Let me have it!

yarn add most-request
#or 
npm install --save most-request

API

request(options: RequestOptions): Stream<Response>

Creates a stream of Response, and upon subscription, will execute the specified request as defined by the given options and emit the Response.

import { request } from 'most-request';
 
request({ url: 'http://example.com', method: 'GET' })
  .observe((response: Response) => {
    ...
  })

Types

The types used in the API section

export interface Response {
    text: string;
    body: any;
    files: any;
    header: any;
    type: string;
    charset: string;
    status: number;
    statusType: number;
    info: boolean;
    ok: boolean;
    redirect: boolean;
    clientError: boolean;
    serverError: boolean;
    error: Error;
    accepted: boolean;
    noContent: boolean;
    badRequest: boolean;
    unauthorized: boolean;
    notAcceptable: boolean;
    notFound: boolean;
    forbidden: boolean;
    xhr: XMLHttpRequest;
    get(header: string): string;
}
 
export declare type HTTPMethod = 
  'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH';
 
export interface RequestOptions {
    url: string;
    method: HTTPMethod;
    query?: Object;
    send?: Object;
    headers?: Object;
    accept?: string;
    type?: string;
    user?: string;
    password?: string;
    field?: Object;
    progress?: boolean;
    attach?: Array<Attachment>;
    agent?: AgentOptions;
    withCredentials?: boolean;
    redirects?: number;
    lazy?: boolean;
}
 
export interface Attachment {
    name: string;
    path: string;
    filename?: string;
}
 
export interface AgentOptions {
    key: string;
    cert: string;
}

Package Sidebar

Install

npm i most-request

Weekly Downloads

1

Version

2.1.0

License

MIT

Last publish

Collaborators

  • tylors
  • motorcyclets
  • frikki