Socket
Socket
Sign inDemoInstall

typed-rest-client

Package Overview
Dependencies
Maintainers
4
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typed-rest-client

Node Rest and Http Clients for use with TypeScript


Version published
Maintainers
4
Created

What is typed-rest-client?

The typed-rest-client npm package is a lightweight HTTP client library for TypeScript and JavaScript. It provides a strongly-typed interface for making HTTP requests, handling responses, and managing authentication. It is particularly useful for interacting with RESTful APIs in a type-safe manner.

What are typed-rest-client's main functionalities?

HTTP Requests

This feature allows you to make HTTP GET requests to a specified URL and handle the response. The example demonstrates how to create a RestClient instance and make a GET request to an API endpoint.

const { RestClient } = require('typed-rest-client/RestClient');

const client = new RestClient('my-user-agent');

async function getData() {
  let res = await client.get('https://api.example.com/data');
  console.log(res.result);
}

getData();

HTTP POST Requests

This feature allows you to make HTTP POST requests to a specified URL with a payload. The example demonstrates how to create a RestClient instance and make a POST request to an API endpoint with a JSON payload.

const { RestClient } = require('typed-rest-client/RestClient');

const client = new RestClient('my-user-agent');

async function postData() {
  let res = await client.create('https://api.example.com/data', { key: 'value' });
  console.log(res.result);
}

postData();

Authentication

This feature allows you to handle authentication using various methods such as Basic Authentication. The example demonstrates how to create a RestClient instance with Basic Authentication and make a GET request to an API endpoint.

const { RestClient } = require('typed-rest-client/RestClient');
const { BasicCredentialHandler } = require('typed-rest-client/Handlers');

const handler = new BasicCredentialHandler('username', 'password');
const client = new RestClient('my-user-agent', null, [handler]);

async function getData() {
  let res = await client.get('https://api.example.com/data');
  console.log(res.result);
}

getData();

Other packages similar to typed-rest-client

Keywords

FAQs

Package last updated on 30 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc