Nyro HTTP Request Library

2.0.4 · active · verified Wed Apr 22

Nyro is a promise-based HTTP and HTTP/2 request library for JavaScript and TypeScript, currently stable at version 2.0.4. It offers comprehensive support for all HTTP methods and focuses on performance and flexibility, incorporating features like proxy support, request queueing, caching mechanisms, and built-in pagination APIs. The library provides robust error handling, retries, and configurable timeouts. While it ships with TypeScript types, it is primarily designed for Node.js environments. Its "browser support" refers to browser-like features within Node rather than client-side browser usage. The project appears actively maintained with recent updates and differentiates itself by providing advanced functionalities such as `bodySchema` for response validation and specialized proxy tools.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates a basic promise-based GET request, including URL parameters, HTTP method, expected response type, custom headers, and response body schema validation using Nyro. It logs the status code and the parsed AI reply.

import nyro, { ResponseType, Method } from 'nyro';

(async() => {

 const { body, statusCode } = await nyro({
    url: 'https://hercai.onrender.com/v3/hercai',
    params: {
        question: 'Hi How Are You?'
    },
    method: Method.Get, // Or 'GET'
    responseType: ResponseType.Json, // Or 'json'
    headers: {
        'User-Agent': 'Nyro-App/1.0'
    },
    bodySchema: {
        content: String,
        reply: String
    }
 });

  console.log(`Status Code: ${statusCode}`);
  console.log('Your Question; ' + body.content);
  console.log('AI Reply; ' + body.reply);

})();

view raw JSON →