Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

al-http-request

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

al-http-request

A simple yet powerful HTTP and HTTPS request library with extensive support for cookies, headers, query parameters, and body payloads.

  • 1.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
25
decreased by-86.7%
Maintainers
0
Weekly downloads
 
Created
Source

#Http request support for cookies, headers, query parameters, and request bodies.

Installation

Before using this module, install the necessary dependencies:

npm install al-http-request

Usage

Import the function

import { req } from 'al-http-request';

Perform a Request

The req function supports the following options:

  • method (optional): HTTP method (GET, POST, PUT, DELETE). Default: GET.
  • headers (optional): Object of headers.
  • cookies (optional): Object of cookies.
  • params (optional): Query parameters.
  • body (optional): Request payload (JSON format).
Example: GET Request with Query Parameters
const response = await req('https://example.com/api', {
  params: { search: 'term', limit: 10 },
});
console.log(response.content);
Example: POST Request with Headers, Cookies, and Body
const response = await req('https://example.com/login', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  cookies: { session: 'abc123' },
  body: { username: 'user', password: 'pass' },
});
console.log(response.content);
Example: Handle Errors
try {
  const response = await req('https://example.com/404');
  console.log(response.content);
} catch (error) {
  console.error(error.message);
}

Features

  • Cookies: Automatically managed using tough-cookie.
  • Headers: Pass custom headers as an object.
  • Query Parameters: Add query parameters easily.
  • JSON Body: Pass a JSON payload for POST/PUT requests.

License

This module is free to use for educational and personal projects.

FAQs

Package last updated on 15 Nov 2024

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