@yucom/rest-client
TypeScript icon, indicating that this package has built-in type declarations

0.2.5 • Public • Published

rest-client

import { connect } from '@yucom/rest-client';

const client = connect('http://localhost:8989');

const john = await client.get.people[123]();  // GET /people/123

const phones = await client.list.people[123].phones({type: 'mobile'});  // GET /people/123/phones?type=mobile

const john = await client.create.people({ name: 'John', lastname: 'Connor' }); // POST /people {"name":"John","lastname":"Connor"}

const john = await client.update.people[123]({ age: 27 }); // PATCH /people/123 {"age":27}

const john = await client.replace.people[123]({ name: 'Carl', lastname: 'Connor' });  // PUT /people/123 {"name":"John","lastname":"Connor"}

await client.remove.people[123](); // DELETE /people/123

const result = await client.invoke.admin/doStuff({ param1: 'Hello', param2: 2.21 });  // POST /admin/doStuff {"param1":"Hello","param2":"2.21"}

Readme

Keywords

none

Package Sidebar

Install

npm i @yucom/rest-client

Weekly Downloads

2

Version

0.2.5

License

ISC

Unpacked Size

84.9 kB

Total Files

40

Last publish

Collaborators

  • leolobeto