1.0.0--.1 • Published 1 year ago

freecycle-api v1.0.0--.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Freecycle API

Library for fetching data from freecycle.org

Install

Add the package:

# npm
npm install freecycle-api

# yarn
yarn add freecycle-api

# pnpm
pnpm add freecycle-api

Usage

The library exports two functions fetchTowns and fetchPosts, which are both fully typed.

import { fetchTowns, fetchPosts } from "freecycle-api";

// Fetch all the towns available on Freecycle
const groupData = await fetchTowns();
// => { groups: { name: string, .. }, .. }

// Fetch all the posts for a given town
const townData = await fetchPosts("BirminghamUK");
// => { posts: { id: string, .. }, .. }

// Example: find all the available offers
const offersInBirmingham = townData.posts.filter(
  ({ type }) => type.const === "FC_POST_OFFER"
);
1.0.0--.1

1 year ago

1.0.0

1 year ago