@element-ts/palladium
A type-safe promise based http/s request library.
Last updated 21 days ago by ejc .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @element-ts/palladium 
SYNC missed versions from official npm registry.

palladium

A type-safe promise based http/s request library.

Example

In the following example you create a PDRequest instance via the post() static method and then using builder methods you can add the correct attributed to the request and then at the end call the async method request(). This will return a PdResponse instance.

On the response instance there are helpful methods to handle type checking. Getting the headers, status code are obvious. However, you can get the raw body or use the json() method. This required an OObjectTypeDefinition which you can learn more about in element-ts/oxygen. This will return undefined if the response does not match the type definition provided, or return a generic defined value based on the type definition.

import {OStandardType} from "@element-ts/oxygen";
import {PdRequest, PdResponse} from "@element-ts/palladium";
const res: PdResponse = await PdRequest
    .post()
    .url("https://api.com/my-endpoint")
    .token("xxx")
    .body({
    	email: "elijah@elijahcobb.com",
    	password: "1234"
    })
    .request();

console.log(res.status());
console.log(res.headers());
console.log(res.json({
    token: OStandardType.string,
    timestamp: OStandardType.number
}));

Documentation

You can view the declaration files or even the source code on GitHub.

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

  • 2.0.7                                ...           latest (21 days ago)

9 Versions

  • 2.0.7                                ...           21 days ago
  • 2.0.6                                ...           21 days ago
  • 2.0.5                                ...           21 days ago
  • 2.0.4                                ...           21 days ago
  • 2.0.3                                ...           21 days ago
  • 2.0.2                                ...           21 days ago
  • 2.0.1                                ...           21 days ago
  • 2.0.0                                ...           21 days ago
  • 0.1.0                                ...           4 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 81
Dependencies (2)
Dev Dependencies (5)

Copyright 2014 - 2016 © taobao.org |