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

pup-fetch

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pup-fetch

A tiny pupper that fetches for you

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source


🐶



DeepSource DeepSource

A tiny pupper that fetches for you, pup is a slim wrapper around fetch

Installation

pnpm install pup-fetch
npm install pup-fetch
yarn install pup-fetch

Usage

Import the methods you need from the module:

import { get, post } from "http-api-wrapper";

GET Requests

Make a GET request using the get method:

const response = await get<MyResponseType>("/api/my-endpoint");

The get method takes two arguments: the path to the endpoint and an optional configuration object. The configuration object can include a baseUrl property to specify a base URL to prepend to the endpoint path.

POST Requests

Make a POST request using the post method:

const body = { name: "John Doe", email: "john.doe@example.com" };
const response = await post<MyResponseType>("/api/my-endpoint", body);

The post method takes three arguments: the path to the endpoint, the request body, and an optional configuration object. Like with get, the configuration object can include a baseUrl property.

Configuration

The RequestConfig interface defines the configuration options for HTTP requests. The following properties are available:

  • baseUrl: The base URL to prepend to the endpoint path.
  • method: The HTTP method to use (e.g. GET, POST, PUT, DELETE).
  • headers: An object containing HTTP headers to include in the request.
  • body: The request body, as a string or an object that can be serialized to JSON.
  • mode: The request mode, which can be "cors", "no-cors", "same-origin", or "navigate".
  • cache: The cache mode, which can be "default", "no-store", "reload", "no-cache", "force-cache", or "only-if-cached".
  • redirect: The redirect mode, which can be "follow", "error", or "manual".

Keywords

FAQs

Package last updated on 13 Mar 2023

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