2.15.0 • Published 2 years ago

@nelreina/rest-client v2.15.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

@nelreina/rest-client

A simple rest client , abstraction of axios

Migration from 1

Version 1

const jsonService = RestClient("https://jsonplaceholder.typicode.com");

Version 2 is Class Based

const options = {};
const jsonService = new RestClient(
  "https://jsonplaceholder.typicode.com",
  options
);

Usage / Example

import RestClient from "@nelreina/rest-client";
const jsonService = new RestClient("https://jsonplaceholder.typicode.com");
const xmlService = new RestClient("http://localhost:1234", { mimetype: "xml" });

// Basic Authorization
const basicAuth = { username: "", password: "" };
const authService = new RestClient("http://localhost:1234", { basicAuth });

// Call the api
try {
  // Get route
  const data = await jsonService.get("/todos/1");

  // POST route
  const data2 = await xmlService.post("/test", { message: "post me" });
} catch (error) {
  console.log(error.message);
}

Options

fielddefaultvalue
mimetypejson'xml' or 'json'
basicAuthnull{'username': '', 'password': ''}
2.12.0

2 years ago

2.15.0

2 years ago

2.13.0

2 years ago

2.14.0

2 years ago

2.11.0

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

2.3.0

2 years ago

2.2.0

2 years ago

2.5.0

2 years ago

2.4.1

2 years ago

2.10.0

2 years ago

2.4.0

2 years ago

2.7.0

2 years ago

2.6.0

2 years ago

2.9.0

2 years ago

2.8.0

2 years ago

2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago