
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
gridsome-source-rest
Advanced tools
Pull data from any REST API into your Gridsome site (ex. Facebook, Instagram, Twitter, Amazon etc)
Pull data from any REST API as a source for your Gridsome site.
The demo below is very simple and shows how to pull data from GitHub Gist or from a dummy REST server. It is however possible to pull data from literally anywhere with it, for example: Twitter, eBay, Amazon, Facebook, Instagram and so on.
If you need frequent data updates check if your REST provider supports webhooks that can trigger your site build or schedule your builds frequently.
yarn add gridsome-source-rest
npm install gridsome-source-rest --save
module.exports = {
plugins: [
{
use: "gridsome-source-rest",
options: {
debug: false,
axiosConfig: undefined,
endpoint: "http://your-api/posts",
typeName: "BlogPost",
isStatic: false,
isCollection: true,
responseInterceptor: undefined
}
}
]
};
In your templates use something like this
<page-query>
query {
allBlogPost {
edges {
node {
id
title
author
}
}
}
}
</page-query>
boolean
Enables log messages
string
requiredThe collection where our REST API data is stored. Depending on isStatic / isCollection this will either be a standalone collection or used as a name property in metadata
string
requiredREST API endpoint that will be used to fetch data
object
Axios config that can be passed and used for example to handle authentication of a private REST API
[boolean]
Stores fetched data in a new collection created with typeName
[boolean]
Stores fetched data in the global metadata object. In case your data model is an array, it will be stored with typeName as property
[function]
Interceptor function that receives the API response and let´s you modify it on the fly before data is getting added to the Gridsome collection
Based on axios and allows setting axios configurations, which allows you to even use authenticated APIs.
v1.0.11 (06.10.2020)
FAQs
Pull data from any REST API into your Gridsome site (ex. Facebook, Instagram, Twitter, Amazon etc)
The npm package gridsome-source-rest receives a total of 30 weekly downloads. As such, gridsome-source-rest popularity was classified as not popular.
We found that gridsome-source-rest demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.