UNPKG

gatsby-source-nytimes-books-api

Version:

This [GatsyJS](https://gatsbyjs.org) source plugin fetches data from the [NYTimes Books API](https://developer.nytimes.com/docs/books-product/1/overview)

21 lines (17 loc) 564 B
const axios = require("axios") const getToday = require("./getToday") const getResults = require("./getResults") const { NYTIMES_API, LISTS_PATH, LISTS_OVERVIEW_ENDPT, } = require("../constants") function getListOverview(options, reporter) { const { token, date = getToday() } = options return axios( `${NYTIMES_API}${LISTS_PATH}${LISTS_OVERVIEW_ENDPT}?api-key=${token}&published_date=${date}` ) .then(data => getResults(data)) .catch(err => reporter.error(`Could not get book list overview: ${err}`)) } module.exports = getListOverview