Source plugin for pulling data into Gatsby from NewsAPI.
npm i --save gatsby-source-newsapi
// In your gatsby-config.js
plugins: [
{
resolve: `gatsby-source-newsapi`,
options: {
apiKey: `YOUR_NEWSAPI_KEY_HERE`,
},
},
];
Get the Top Headlines
{
allNewsApiTopHeadlines {
edges {
node {
source {
id
name
}
title
author
description
url
urlToImage
publishedAt
}
}
}
}