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

@donation-alerts/api-call

v3.0.1

Published

Make calls to Donation Alerts API.

Downloads

31

Readme

Donation Alerts - Api Call

A basic Donation Alerts API call wrapper.

This package contains simple utils that allow you to send requests to different Donation Alerts API endpoints with given credentials.

If you need to use the Donation Alerts API, consider using the @donation-alerts/api package, which allows for more flexibility and convenience in requesting data from the Donation Alerts API. The @donation-alerts/api package already uses this package internally, so you don't need to install it separately.

But if you still need it:

Installation

Using npm:

npm i @donation-alerts/api-call

Using yarn:

yarn add @donation-alerts/api-call

Usage

You can call Donation Alerts API in one of two ways:

  1. Using callDonationAlertsApiRaw() function to get native Response object.
  2. Using callDonationAlertsApi<T>() function to get only payload data. You can specify data type in the type parameter T.

The both functions accepts the same arguments:

You can do the following to request raw data, for example, from alerts/donations endpoint:

import { callDonationAlertsApiRaw } from '@donation-alerts/api-call';

// Assuming we are inside an async funcation or with top level `await` enabled.
const response = await callDonationAlertsApiRaw(
	{
		url: 'alerts/donations'
	},
	'<YOUR_ACCESS_TOKEN>'
);

The response will be native Response object of the Fetch API.

To request only payload mapped data, you can do the following:

import { callDonationAlertsApi } from '@donation-alerts/api-call';

// Create an interface that represents the data you expect to receive.
interface PayloadData {
	// ...
}

const response = await callDonationAlertsApi<PayloadData>(
	{
		url: '<endpoint>'
	},
	'<your access token>'
);

The response will be mapped to the PayloadData interface that we passed as a type parameter.

The function above can throw the HttpError which you can catch and use.


For more information check the documentation.