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

http-status-toast

v1.5.1

Published

A simple toast notification according to your http req response!

Downloads

16

Readme

HTTP STATUS TOAST

Introducing a straightforward and practical library designed to assist developers in effectively notifying users about the status of their requests. 😁

✨ Release 🚀 Check on releases on source repository!

Description

This library offers a simple, concise, and versatile solution, making it easier than ever for developers to communicate essential information to users. With its user-friendly approach, it simplifies the process of conveying the current state of requests, ensuring a seamless user experience. Whether you need to provide updates, alerts, or general notifications, this library has got you covered, enabling you to streamline your development process while delivering clear and informative messages to your users.

License

MIT License

Suggestions and Issues

Suggestions are always welcome!

Please, if you have a suggestion or issue to do, create an issue at this repo. Follow this example:

[ToastHeader] Alignments with alignment error

And inside of it, your description of the suggestion/issue.

Thank you 🚀✨

Installation

Install http-status-toast using npm

  npm install http-status-toast

Demonstration

For use in the simplest way:

fetch(URL)
    .then((response) => setData(response.data))
    .catch((error) => httpStatusToast(response.status, 'en'))

Above we have a simple call of the lib function, that will call a notification with a simple message and a simple toast with its theme according to the status passed by params.

Default examples by status

Here we will have some examples of the simplest use of this function, passing just the status and the english lang to the function.

  • When the status passed it fits successfull request:
  • When the status passed it fits client error request:
  • When the status passed it fits server error request:
  • When the status passed it fits unknown type of request:

But if you want to customize more and more, we have some optionals uses for this function.

You can costume:

  • Style by customStyle params, JSON format
  • Horizontal position by position params, passing "right" or "left" values
  • Language by lang params, for now we have just for portuguese ("pt"), spanish ("es") and english ("en")
  • Toast duration by duration params, passing milisseconds value
  • Custom message by message params, passing a string or a React Node
  • Custom header by customHeader params, passing a string or a React Node

Storybook controls visualization

Examples of uses:

  • Style
fetch(URL)
    .then((response) => httpStatusToast({
        status: response.status,
        lang: 'en',
        customStyle: { "font-family": "Times new Roman", "color": "red" }
    }))
    .catch((error) => console.error(error))
  • Position
fetch(URL)
    .then((response) => httpStatusToast({
        status: response.status,
        lang: 'en',
        position: "left"
    }))
    .catch((error) => console.error(error))
  • Language
fetch(URL)
    .then((response) => httpStatusToast({
        status: response.status,
        lang: 'pt'
    }))
    .catch((error) => console.error(error))
  • Duration
fetch(URL)
    .then((response) => httpStatusToast({
        status: response.status,
        lang: 'pt',
        duration: 6000, // 6 seconds
    }))
    .catch((error) => console.error(error))
  • Message
fetch(URL)
    .then((response) => httpStatusToast({
        status: response.status,
        lang: 'en',
        message: response.data.message || <div>Lorem ipsum <SomeIcon /></div>,
    }))
    .catch((error) => console.error(error))
  • Custom header
fetch(URL)
    .then((response) => httpStatusToast({
        status: response.status,
        lang: 'en',
        customHeader: "Lorem ipsum" || <div>Lorem ipsum <SomeIcon /></div>,
    }))
    .catch((error) => console.error(error))

And that's it! ❤️

Thank you for using my first lib, and thank you for reading till here!

Created by me @ninamarq 🚀✨