Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stuft

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stuft

A news api.

  • 1.0.4
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Stuft

A simple news API. Use at your own risk.

API

The stuft module exposes one function that handles network requests and parsing. It returns a Promise, meaning you can also use the async/await syntax.

You can call the stuft function with several options. You can mix these options except when id is present, then limit and section have no effect. Find out what fetchOptions you can pass in here: https://github.github.io/fetch/#options.

Examples:

Getting articles

import stuft from "stuft";

// Using async/await
(async () => {
  // get the first 5 articles
  const articles = await stuft();
  for (const article of articles) {
    console.log(article.id, article.title);
  }
})();

Getting articles from a specific section

import stuft, { Section } from "stuft";

// Using Promises:
(() => {
  // get the first 5 articles from the business section
  stuft({ section: Section.Business })
    .then((articles) => {
      for (const article of articles) {
        console.log(article.id, article.title);
      }
    })
    .catch((err) => {
      console.error(err);
    });
})();

Getting more than 5 articles

import stuft from "stuft";

// Using async/await
(async () => {
  // get the first 20 articles
  const articles = await stuft({ limit: 20 });
  for (const article of articles) {
    console.log(article.id, article.title);
  }
})();

Getting a specific article

import stuft from "stuft";

// Using async/await
(async () => {
  // get a specific article
  const articles = await stuft({ id: 109912957 });
  const article = articles[0];
  console.log(article.id, article.title);
})();

FAQs

Package last updated on 14 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc