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

@coconut-packages/cds

v1.0.4

Published

This repository contains a central data service script built over Axios to streamline and manage API calls. It is designed as a reusable package that can be imported into main applications.

Readme

Central Data Service Wrapper over Axios

This repository contains a central data service script built over Axios to streamline and manage API calls. It is designed as a reusable package that can be imported into main applications.

Features

  • Simplifies API calls with dynamic configuration.
  • Global error handling.
  • Request and response interceptors for additional processing.
  • Support for GET, POST, PUT, DELETE, and other HTTP methods.
  • Base URL management.
  • Easy to extend with retries, logging, and more.

Installation

  1. Install the package via npm or yarn:

    npm install central-data-service

    or

    yarn add central-data-service
  2. Import and use the service in your main application.

Usage

1. Import and Initialize

Import the central data service and optionally set the base URL:

import CentralDataService from 'central-data-service';

// Default instance with base URL (example: https://api.example.com)
const apiService = new CentralDataService('https://api.example.com');

2. Sample Configurations

GET Request Config:

const getConfig = {
  method: 'GET',
  url: '/users',
  params: { page: 1, limit: 10 }, // Query parameters
  headers: { Authorization: 'Bearer <token>' }, // Custom headers
};

POST Request Config:

const postConfig = {
  method: 'POST',
  url: '/users',
  data: { name: 'John Doe', email: '[email protected]' }, // Request body
  headers: { Authorization: 'Bearer <token>' }, // Custom headers
};

3. Making API Calls

Call the makeRequest method with the configuration:

Fetching Users:

async function fetchUsers() {
  try {
    const response = await apiService.makeRequest(getConfig);
    console.log('Users:', response);
  } catch (error) {
    console.error('Error fetching users:', error.message);
  }
}

Creating a User:

async function createUser() {
  try {
    const response = await apiService.makeRequest(postConfig);
    console.log('User created:', response);
  } catch (error) {
    console.error('Error creating user:', error.message);
  }
}

4. Extending Functionality

You can customize the Axios instance to include features like:

  • Authentication tokens: Add logic to include tokens in the request headers.
  • Retries: Add retry logic for failed requests.
  • Caching: Implement caching for repeated requests.

Modify interceptors in the CentralDataService constructor as needed:

this.client.interceptors.request.use(
  (config) => {
    // Add tokens or modify headers
    config.headers['Authorization'] = `Bearer <token>`;
    return config;
  },
  (error) => Promise.reject(error)
);

Example Project Structure

src/
├── services/
│   └── CentralDataService.js
├── components/
│   └── ExampleComponent.js
├── App.js
└── index.js

Dependencies

  • Axios: Promise-based HTTP client for the browser and Node.js.

Contributing

Contributions are welcome! Feel free to submit a pull request or raise an issue for bug fixes, feature requests, or improvements.

License

This project is licensed under the MIT License. See the LICENSE file for more details.