This package has been deprecated

Author message:

Please rely on a standard tool like node-fetch

@travetto/net

1.0.5 • Public • Published

Network

Network utilities of the travetto framework

Install: @travetto/net

npm install @travetto/net

HTTP Requests

The http request functionality exists to allow for simple usage of the node http and https modules. HttpRequest exists, in lieu of alternatives, as a means to provide the smallest footprint possible. Using it is fairly straightforward:

Code: Using HttpRequest

import { HttpRequest } from '@travetto/net';

HttpRequest.exec({
  url: 'https://gooogle.com',
}).then(res => {
  console.log(res);
});

Or a more complex example:

Code: Using HttpRequest to Make API Calls

import { HttpRequest } from '@travetto/net/src/request';

interface User {
  id: number;
  name: string;
}

HttpRequest.execJSON<User>({
  url: 'https://localhost:3000/api',
  method: 'post',
}, { id: 5, name: 'Test' }).then(res => {
  console.log(res.name);
});

Package Sidebar

Install

npm i @travetto/net

Homepage

travetto.io

Weekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

11.9 kB

Total Files

7

Last publish

Collaborators

  • arcsine