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

paado

v1.1.0

Published

Paado - Simplify API Requests with Ease Paado is an API helper package designed to make working with APIs more intuitive and efficient by leveraging the power of Axios. Inspired by the metaphor of an API acting like a waiter, the package's name, "Paado,"

Downloads

640

Readme

Paado

Paado is a lightweight JavaScript library designed to simplify making HTTP requests to a server while managing authentication tokens efficiently. It utilizes Axios under the hood for making requests, allowing for a seamless integration into your front-end projects.

Features

  • Automatically retrieves authentication tokens from localStorage or cookies.
  • Configurable base URL and timeout settings.
  • Customizable headers for each request.

Installation

You can install Paado using npm:

npm install paado

Usage

Basic Setup

To get started with Paado, you first need to configure it with your desired settings. Here’s a quick example of how to do that:

import { configure, request } from 'paado';

// Set configuration
configure({
    baseURL: 'https://api.example.com',
    timeout: 15000,
    tokenName: 'authToken',
    tokenKey: 'Bearer',
    tokenLocation: 'localStorage',
    headers: {
        'Custom-Header': 'value'
    }
});

Making Requests

You can make requests using the request function. Here’s an example of how to perform a GET and POST request:

GET Request

async function fetchData() {
    try {
        const data = await request('GET', '/data-endpoint');
        console.log(data);
    } catch (error) {
        console.error('Error fetching data:', error);
    }
}

fetchData();

POST Request

async function postData() {
    try {
        const response = await request('POST', '/submit-data', { key: 'value' });
        console.log(response);
    } catch (error) {
        console.error('Error posting data:', error);
    }
}

postData();

Configuration

You can customize the configuration using the configure function. The configuration object can contain the following fields:

  • baseURL: (string) The base URL for all requests.
  • timeout: (number) The timeout for requests in milliseconds (default: 10000).
  • tokenName: (string) The name of the token to retrieve from localStorage or cookies (default: 'authToken').
  • tokenKey: (string) The prefix for the token in the Authorization header (default: 'Bearer').
  • tokenLocation: (string) Where to retrieve the token from (localStorage or cookie) (default: 'localStorage').
  • headers: (object) Additional headers to be included in every request.

Example Configuration

configure({
    baseURL: 'https://api.example.com',
    tokenLocation: 'cookie', // or 'localStorage'
});