Nanobot: Polygonal Mascot

    @faasjs/request
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.3-beta.10 • Public • Published

    @faasjs/request

    License: MIT NPM Stable Version NPM Beta Version

    FaasJS's request module.

    Install

    npm install @faasjs/request
    

    Modules

    Type Aliases

    Functions

    Type Aliases

    Request

    Ƭ Request: Object

    Type declaration

    Name Type
    body? { [key: string]: any; }
    headers? http.OutgoingHttpHeaders
    host? string
    method? string
    path? string
    query? http.OutgoingHttpHeaders

    RequestOptions

    Ƭ RequestOptions: Object

    Type declaration

    Name Type Description
    agent? boolean -
    auth? string The authentication credentials to use for the request. Format: username:password
    body? { [key: string]: any; } | string -
    downloadStream? NodeJS.WritableStream Create a write stream to download a file.
    file? string Path of uploading a file to the server.
    headers? http.OutgoingHttpHeaders -
    logger? Logger -
    method? string The HTTP method to use when making the request. Defaults to GET.
    parse? (body: string) => any Body parser. Defaults to JSON.parse.
    passphrase? string -
    pfx? Buffer -
    query? { [key: string]: any; } -
    timeout? number -

    Response

    Ƭ Response<T>: Object

    Type parameters

    Name Type
    T any

    Type declaration

    Name Type
    body T
    headers http.OutgoingHttpHeaders
    request? Request
    statusCode? number
    statusMessage? string

    Functions

    querystringify

    querystringify(obj): string

    Parameters

    Name Type
    obj any

    Returns

    string


    request

    request<T>(url, options?): Promise<Response<T>>

    Request

    Url

    https://faasjs.com/doc/request.html

    Type parameters

    Name Type
    T any

    Parameters

    Name Type Description
    url string Url
    options? RequestOptions Options

    Returns

    Promise<Response<T>>


    setMock

    setMock(handler): void

    Mock requests

    Example

    setMock(async (url, options) => Promise.resolve({ headers: {}, statusCode: 200, body: { data: 'ok' } }))

    Parameters

    Name Type Description
    handler Mock {function | null} null to disable mock

    Returns

    void

    Keywords

    none

    Install

    npm i @faasjs/request

    DownloadsWeekly Downloads

    539

    Version

    0.0.3-beta.10

    License

    MIT

    Unpacked Size

    18.6 kB

    Total Files

    6

    Last publish

    Collaborators

    • zfben