Skip to content
This repository has been archived by the owner on Dec 3, 2022. It is now read-only.

Commit

Permalink
Add workaround for Pinboard API issue
Browse files Browse the repository at this point in the history
  • Loading branch information
danoc committed Jun 24, 2020
1 parent 7463df7 commit 93c800a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/gatsby-node.js
Expand Up @@ -9,7 +9,18 @@ exports.sourceNodes = async ({ actions }, { authToken, tags }) => {
// https://pinboard.in/api/#posts_recent
`https://api.pinboard.in/v1/posts/recent?auth_token=${authToken}&format=json&count=100${tagsQuery}`
);
const data = await res.json();

// We'd normally use `res.json()`, but a Pinboard API bug prevents this from
// working.
// https://twitter.com/Pinboard/status/1275764946182144002
// https://github.com/node-fetch/node-fetch/issues/541
let text = await res.text();

if (text.charCodeAt(0) === 0xfeff) {
text = text.substr(1);
}

const data = JSON.parse(text);

// Process data into nodes.
data.posts.forEach((post) => {
Expand Down

0 comments on commit 93c800a

Please sign in to comment.