npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fetch-xy

v0.2.2

Published

A Fetch API wrapper with some extra features

Readme

FetchXY

FetchXY is a lightweight and flexible HTTP client for TypeScript/JavaScript applications, providing a simple interface for making HTTP requests with built-in timeout handling, retries, and error management.

Features

  • 🚀 Promise-based HTTP client
  • ⚡ Automatic timeout handling
  • 🔄 Request retries with configurable conditions
  • 📦 TypeScript support
  • 🛠 Configurable defaults
  • 🎯 Simple and intuitive API

Installation

npm install fetch-xy

Usage

Basic Example

import FetchXY from 'fetch-xy';

const client = new FetchXY();

// Make a GET request
const response = await client.get('https://api.github.com/users/octocat');
console.log(response);
// Response will include:
// {
//   data: { ... },        // Response data
//   status: 200,          // HTTP status code
//   success: true,        // Boolean indicating if status is 2xx
//   headers: { ... },     // Response headers
//   attempts: 0,          // Number of retry attempts made
//   retries: 0,          // Total retries configured
//   retryDelay: 1000     // Delay between retries in ms
// }

// Make a request with retries
const responseWithRetries = await client.get('https://api.github.com/users/octocat', {
  retries: 3,             // Retry up to 3 times
  timeout: 5000,          // Timeout after 5 seconds
  retryDelay: 1000,       // Wait 1 second between retries
  retryIf: [408, 500]     // Only retry on timeout or server error
});

Advanced Configuration

const client = new FetchXY({
  // Default timeout of 5 seconds
  timeout: 5000,
  
  // Retry failed requests up to 3 times
  retries: 3,
  
  // Wait 2 seconds between retries
  retryDelay: 2000,
  
  // Retry on specific HTTP status codes
  retryIf: [408, 500, 502, 503, 504],
  
  // Default headers
  headers: {
    'Authorization': 'Bearer your-token'
  }
});

Retry Configuration Examples

// Retry only on timeout (408) and server errors (500)
const client = new FetchXY({
  retries: 2,
  retryIf: [408, 500]
});

// Custom retry delay with specific status codes
const response = await client.get('https://api.example.com/data', {
  retries: 3,
  retryDelay: 1000, // 1 second between retries
  retryIf: [503, 504] // Retry only on service unavailable
});

// Timeout configuration
const response = await client.post('https://api.example.com/data', {
  timeout: 3000, // 3 second timeout
  retries: 2,    // Retry twice if timeout occurs
  data: {
    name: 'John Doe'
  }
});

Available Methods

  • get(url, config)
  • post(url, config)
  • put(url, config)
  • delete(url, config)
  • patch(url, config)

Development

Prerequisites

  • Node.js (v20 or higher)
  • npm or yarn

Setting Up the Development Environment

  1. Clone the repository:
git clone https://github.com/cardoso222/FetchXY.git
cd FetchXY
  1. Install dependencies:
npm install
  1. Build the project:
npm run build

Running Tests

npm test

Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Contribution Guidelines

  • Write clear and descriptive commit messages
  • Add tests for new features
  • Update documentation as needed
  • Follow the existing code style
  • Make sure all tests pass before submitting a PR

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you encounter any issues or have questions, please file an issue on the GitHub repository.