TopStories - randomSection

Example

example.js
const { TopStories } = require('nytimes-api');
const top = new TopStories('your-super-secret-api-key');

top.randomSection(data => console.log(data));

What does it do?

randomSection returns a random section from the array you get if you were to use sections. The code example above does the same.

This is not a feature in the API. It has just been added to the wrapper for convenience.

Example Response

example-response.json
'opinion'

Last updated