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

emd-rest

v0.0.8

Published

Helper REST API

Downloads

13

Readme

emd-rest 🚀

npm Travis (.org) license npm downloads node version GitHub code size in bytes GitHub top language GitHub last commit GitHub issues

DESCRIPTION: Introducing a refined HTTP client experience, our library takes inspiration from Axios, providing all its powerful features, but with an added twist. Our library seamlessly integrates advanced logging capabilities. Every request and response, along with relevant metadata, is conveniently printed to the console, making debugging and tracking easier than ever. For developers who seek clarity and transparency in their HTTP requests without additional setup, this is the tool to elevate your development workflow.

📖 Table of Contents

📦 Installation

npm install emd-rest

or

yarn add emd-rest

💡 Examples

To get started with emd-rest, import it in your project:

const restHelper = require('emd-rest');

or

import restHelper from 'emd-rest';

Example usage:

restHelper.get("https://jsonplaceholder.typicode.com/todos/1", {params: {id: 1}})
.then( res => console.log(res))
.catch( err => console.log(err));

in async await function:

async function getTodo() {
    try {
        const res = await restHelper.get("https://jsonplaceholder.typicode.com/todos/1", {params: {id: 1}});
        console.log(res);
    } catch (err) {
        console.log(err);
    }
}

arrow function async await:

const getTodo = async () => {
    try {
        const res = await restHelper.get("https://jsonplaceholder.typicode.com/todos/1", {params: {id: 1}});
        console.log(res);
    } catch (err) {
        console.log(err);
    }
}

POST request with data and config:

const data = {
    title: 'foo',
    body: 'bar',
    userId: 1,
};

const config = {
    timeout: 1000,
    withCredentials: true,
    httpsAgent: new https.Agent({ keepAlive: true }),
};

restHelper.post("https://jsonplaceholder.typicode.com/posts", data, config)
.then( res => console.log(res))
.catch( err => console.log(err));

PUT request with headers and data:

const headers = {
    'Content-type': 'application/json; charset=UTF-8',
};

const data = {
    title: 'foo',
    body: 'bar',
    userId: 1,
};

restHelper.put("https://jsonplaceholder.typicode.com/posts/1", data, {headers})
.then( res => console.log(res))
.catch( err => console.log(err));

DELETE request with headers and data:

const headers = {
    'Content-type': 'application/json; charset=UTF-8',
};

const data = {
    title: 'foo',
    body: 'bar',
    userId: 1,
};

restHelper.delete("https://jsonplaceholder.typicode.com/posts/1", {headers, data})
.then( res => console.log(res))
.catch( err => console.log(err));

PATCH request with data:

const data = {
    title: 'foo',
    body: 'bar',
    userId: 1,
};

restHelper.patch("https://jsonplaceholder.typicode.com/posts/1", data)
.then( res => console.log(res))
.catch( err => console.log(err));

📘 API Documentation

get(url, [config])

Sends a GET request to the specified URL.

Parameters:

  • url (string): The URL to which the request is sent.
  • config (object, optional): Configuration options for the request.

Config Options

  • headers (object): Headers to be added to the request.
  • params (object): URL parameters to be sent with the request.
  • timeout (number): Specifies the number of milliseconds before the request times out.
  • withCredentials (boolean): Indicates whether or not cross-site Access-Control requests should be made using credentials.

Returns: Promise - A Promise that resolves to the response to the request.

Response Object

The Promise resolves to an object with the following properties:

  • data (object): The response data sent by the server.
  • status (number): The HTTP status code of the response.
  • statusText (string): The status message corresponding to the status code.
  • headers (object): The headers the server responded with.
  • config (object): The configuration used for the request.
  • request (object): The request object.

🤝 Contribute

Contributions, issues, and feature requests are welcome!

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

📜 License

This project is MIT licensed.


Support

If you find any bugs or have a feature request, please open an issue on github!

Stay in touch

👤 Evyatar Madari


❤️ Made with love by Evyatar Madari