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 🙏

© 2024 – Pkg Stats / Ryan Hefner

axios-clt

v1.0.2

Published

An HTTP Client based on Axios.

Downloads

2

Readme

Axios HTTP Client

AxiosClient is a JavaScript class that provides a convenient wrapper around the popular Axios HTTP client library. It simplifies making HTTP requests and offers additional features to handle path resolution, parameter interpolation, and more.

Table of Contents

Features

  • Create a flexible Axios client instance with custom configurations.

  • Resolve API endpoints with path parameters and aliases.

  • Interpolate parameters into API paths for easy request building. Supports HTTP methods like GET, POST, PUT, PATCH, and DELETE.

  • Handle response data with promises, making asynchronous requests easy.

Installation

To use AxiosClient in your project, you can install it via npm or yarn:

yarn add axios-clt
import { AxiosClient } from "axios-clt";

const client = new AxiosClient({
    config: {
        baseURL: "<https://api.example.com>",
        // Add other Axios configuration options here
    },
    aliases: {
        users: "/users",
        user: "/users/:id",
        // Define aliases for common API paths
    },
});

Usage

Here's an example of how to use the AxiosClient to make a GET request:

// Fetch a list of users
const response = await client.get("users");
console.log(response.data); // Handle the response data as needed

// Fetch a single user
const response = await client.get("user", { id: 123 });
console.log(response.data); // Handle the response data as needed

You can use the AxiosClient for other HTTP methods like POST, PUT, PATCH, and DELETE by calling the respective methods on the client instance.

API Reference

AxiosClient(options)

  • options (Object) - Configuration options for the Axios client instance.
    • config (Object) - Axios configuration options (e.g., baseURL, timeout).
    • aliases (Object) - Aliases for common API paths.

client.get(path, params, config)

  • Makes a GET request to the specified path.

client.post(path, data, config)

  • Makes a POST request to the specified path.

client.put(path, data, config)

  • Makes a PUT request to the specified path.

client.patch(path, data, config)

  • Makes a PATCH request to the specified path.

client.delete(path, params, config)

  • Makes a DELETE request to the specified path.

client.resolvePath(path, params)

  • Resolves the path with optional path parameters and aliases.

client.interpolateParams(path, params)

  • Interpolates parameters into the path string.

Contributing

If you find a bug or want to contribute to the project, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Make your changes and ensure tests pass.
  4. Submit a pull request with a clear description of your changes.

License

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

Author

Zakaria Khonchafi - LinkedIn | Twitter