sl-request: Simplified HTTP Client (Fork of Deprecated 'request')

1.0.8 · deprecated · verified Wed Apr 22

sl-request is a Node.js HTTP client, version 1.0.8, explicitly stated as a fork of the widely used but now deprecated `request` library, primarily for internal use by sealights.io. This package attempts to provide a simplified API for making HTTP calls, supporting HTTPS, automatic redirects, streaming, and various request body types (forms, multipart). However, inheriting its core from the original `request` library, it carries the same limitations and risks, including a callback-centric API, known security vulnerabilities, and a lack of modern maintenance. The original `request` library was officially deprecated in February 2020 due to its unmaintained status, security risks, and outdated architectural patterns that do not align with modern JavaScript and Node.js paradigms. Users should be aware that `sl-request` likely shares these fundamental issues and does not offer a current, actively maintained solution for HTTP requests. Release cadence is infrequent, reflecting its internal-use nature and the deprecated status of its upstream.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates basic GET request, streaming a file via PUT, and error handling for stream-based operations, using `sl-request`.

import request from 'sl-request';
import fs from 'fs';

// Basic GET request
request('http://www.google.com', function (error, response, body) {
  if (error) {
    console.error('Error:', error);
    return;
  }
  console.log('statusCode:', response && response.statusCode);
  console.log('Body snippet:', body.substring(0, 100) + '...');
});

// Stream a file to a PUT request
// For demonstration, create a dummy file first
fs.writeFileSync('temp_upload.json', JSON.stringify({ message: 'Hello from sl-request' }));

fs.createReadStream('temp_upload.json')
  .pipe(request.put('http://httpbin.org/put', function (error, response, body) {
    if (error) {
      console.error('PUT Error:', error);
      return;
    }
    console.log('PUT statusCode:', response && response.statusCode);
    console.log('PUT Response:', body);
    fs.unlinkSync('temp_upload.json'); // Clean up dummy file
  }));

// Example of error handling for streaming
request.get('http://nonexistent-domain.invalid/image.png')
  .on('error', function(err) {
    console.error('Streaming error caught:', err.message);
  })
  .pipe(fs.createWriteStream('downloaded_image.png'));

view raw JSON →