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

@smithy/fetch-http-handler

Package Overview
Dependencies
Maintainers
0
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smithy/fetch-http-handler

Provides a way to make requests

  • 4.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19M
decreased by-14.62%
Maintainers
0
Weekly downloads
 
Created

What is @smithy/fetch-http-handler?

@smithy/fetch-http-handler is a package that provides an HTTP handler for making requests using the Fetch API. It is part of the AWS SDK for JavaScript v3 and is designed to work seamlessly with other Smithy components to handle HTTP requests and responses.

What are @smithy/fetch-http-handler's main functionalities?

Basic HTTP Request

This feature allows you to make a basic HTTP GET request using the FetchHttpHandler. The request object specifies the method, hostname, and path for the request.

const { FetchHttpHandler } = require('@smithy/fetch-http-handler');

const handler = new FetchHttpHandler();

const request = {
  method: 'GET',
  hostname: 'example.com',
  path: '/path'
};

handler.handle(request).then(response => {
  console.log(response);
}).catch(error => {
  console.error(error);
});

Custom HTTP Headers

This feature allows you to add custom HTTP headers to your request. The headers object within the request object specifies the custom headers.

const { FetchHttpHandler } = require('@smithy/fetch-http-handler');

const handler = new FetchHttpHandler();

const request = {
  method: 'GET',
  hostname: 'example.com',
  path: '/path',
  headers: {
    'Custom-Header': 'value'
  }
};

handler.handle(request).then(response => {
  console.log(response);
}).catch(error => {
  console.error(error);
});

Handling HTTP Responses

This feature demonstrates how to handle HTTP responses. The response object contains the body, which can be processed further, such as converting it to text.

const { FetchHttpHandler } = require('@smithy/fetch-http-handler');

const handler = new FetchHttpHandler();

const request = {
  method: 'GET',
  hostname: 'example.com',
  path: '/path'
};

handler.handle(request).then(response => {
  return response.body.text();
}).then(body => {
  console.log(body);
}).catch(error => {
  console.error(error);
});

Other packages similar to @smithy/fetch-http-handler

FAQs

Package last updated on 09 Dec 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