CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-rest

tessl install tessl/npm-rest@2.0.0

RESTful HTTP client library with composable interceptor architecture for Node.js and browsers

Agent Success

Agent success rate when using this tile

76%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.29x

Baseline

Agent success rate without this tile

59%

task.mdevals/scenario-3/

Universal API Client

A lightweight HTTP client wrapper that provides a consistent interface for making API requests in both Node.js and browser environments.

Capabilities

Platform Detection and Client Selection

  • It detects when running in Node.js environment and uses the appropriate client @test
  • It detects when running in browser environment and uses the appropriate client @test

Making HTTP Requests Cross-Platform

  • It makes a successful GET request in Node.js environment @test
  • It makes a successful GET request in browser environment @test
  • It makes a POST request with JSON payload in both environments @test

Response Handling

  • It returns a normalized response with status, headers, and entity @test
  • It handles response promise methods like entity() and status() @test

Requirements

The client must:

  1. Work seamlessly in both Node.js and browser JavaScript environments without requiring different code paths for basic usage
  2. Return normalized response objects with consistent structure regardless of the underlying platform
  3. Support basic HTTP methods (GET, POST) with proper request configuration
  4. Handle JSON request and response payloads automatically

Implementation

@generates

API

/**
 * Creates a configured HTTP client that works across platforms
 * @param {object} [config] - Optional configuration for the client
 * @returns {function} Configured client function
 */
function createClient(config);

/**
 * Makes an HTTP request
 * @param {string|object} request - URL or request object with path, method, entity, headers
 * @returns {Promise} Promise resolving to response with status, headers, and entity
 */
function request(urlOrConfig);

module.exports = { createClient, request };

Dependencies { .dependencies }

rest { .dependency }

Provides cross-platform HTTP client functionality with automatic platform detection.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/rest@2.0.x
tile.json