@elijahjcobb/request
A package to send and receive data using promises.
Last updated a year ago by ejc .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @elijahjcobb/request 
SYNC missed versions from official npm registry.

Request

A package to send and receive data using promises.

Import

import { ECRRequest, ECRResponse, ECRMethod } from "@elijahjcobb/request";

Examples

Promises

let req: ECRRequest = new ECRRequest();

req.setUrl("the-url");
req.setMethod(ECRMethod.Post);
req.setBody({ foo: "hello", bar: "world" });

let res: ECRResponse = req.request();

Callbacks

let req: ECRRequest = new ECRRequest();

req.setUrl("the-url");
req.setMethod(ECRMethod.Post);
req.setBody({ foo: "hello", bar: "world" });

req.requestAsync(((error: Error, response: ECRResponse): void => {}));

Documentation

Everything is completely documented. You can view the declaration files or even the source code on GitHub.

ECRRequest

{
    body: Buffer;
    url: string;
    method: Method;
    headers: object;
    constructor();
    setBearerToken(token: string): void;
    setUrl(url: string): void;
    setMethod(method: Method): void;
    setBody(body: string | object | Buffer): void;
    requestAsync(completion: (error: Error, response: Response) => void): void;
    request(): Promise<Response>;
}

ECRResponse

{
    statusCode: number;
    roundTripTime: number;
    body: string | object | Buffer;
    constructor(response: RequestLib.Response, startTimestamp: number);
    getJSON(): object;
    getBuffer(): Buffer;
    getString(): string;
    getRaw(): string | object | Buffer;
    print(): void;
}

ECRMethod

{
    Get = "GET",
    Post = "POST",
    Put = "PUT",
    Delete = "DELETE"
}

Bugs

If you find any bugs please create an issue on GitHub or if you are old fashioned email me at elijah@elijahcobb.com.

Current Tags

  • 0.0.1                                ...           latest (a year ago)

1 Versions

  • 0.0.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (1)
Dev Dependencies (4)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |