Note: This post is a summary of information paraphrased from an excellent blog post by Christian Sepulveda.
Create the app and download the necessary dependencies.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** extracted page creation functionality into smaller functions **/ | |
const path = require('path'); | |
function createBlogPostsPages(result, createPage) { | |
const blogPostTemplate = path.join(__dirname, `../src/templates/blog-post.js`); | |
const blogPosts = result.data.blogs.edges; | |
blogPosts.forEach((post, index) => { | |
const previous = index === blogPosts.length - 1 ? null : blogPosts[index + 1].node; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as qs from "qs"; | |
import { PathLike } from "fs"; | |
export const apiConfig = { | |
returnRejectedPromiseOnError: true, | |
withCredentials: true, | |
timeout: 30000, | |
baseURL: "https://jsonplaceholder.typicode.com/", | |
headers: { | |
common: { |