Skip to content

Commit cd0b80c

Browse files
author
Paul Scanlon
authored
chore(docs): update documentation for node-fetch to use CommonJS (#35129)
1 parent 9690c7c commit cd0b80c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

docs/docs/conceptual/data-fetching.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ module.exports = {
6060
Alternately, if you want to source data yourself you can use APIs Gatsby provides. Source plugins take advantage of the [`sourceNodes` API](/docs/reference/config-files/gatsby-node/#sourceNodes) and the [`createNode` action](/docs/reference/config-files/actions/#createNode) provided by Gatsby to make your data queryable during the build process. If you want to source data yourself you can add a section of code like this using the `createNode` API to add a node to your data layer manually:
6161

6262
```js:title=gatsby-node.js
63-
const fetch = require(`node-fetch`)
63+
const fetch = (...args) =>
64+
import(`node-fetch`).then(({ default: fetch }) => fetch(...args))
6465

6566
exports.sourceNodes = async ({
6667
actions: { createNode },

0 commit comments

Comments
 (0)