AndreasFaust / gatsby-source-custom-api

Source data from any API and transform it to (File-)Nodes.
52 stars 25 forks source link

Make `auth` optional #37

Closed buzinas closed 2 years ago

buzinas commented 2 years ago

Since auth is optional and loadImages currently throws an error when there is no auth, this PR adds a short circuit.

Fixes #36.

I've been using patch-package while the last published version is broken (and it's working nicely):

diff --git a/node_modules/gatsby-source-custom-api/utils/loadImages.js b/node_modules/gatsby-source-custom-api/utils/loadImages.js
index 8c2441e..6b83100 100644
--- a/node_modules/gatsby-source-custom-api/utils/loadImages.js
+++ b/node_modules/gatsby-source-custom-api/utils/loadImages.js
@@ -18,7 +18,7 @@ async function createImageNodes ({
   try {
     fileNode = await createRemoteFileNode({
       url: entity.data.url,
-      auth: { htaccess_user: auth.username, htaccess_pass:  auth.password },
+      auth: auth && { htaccess_user: auth.username, htaccess_pass:  auth.password },
       store,
       cache,
       createNode,
buzinas commented 2 years ago

@AndreasFaust any chance we can merge this?

AndreasFaust commented 2 years ago

Thank you for your contribution.

buzinas commented 2 years ago

Thanks, @AndreasFaust! Any chance we can get it released soon?

AndreasFaust commented 2 years ago

Released v2.3.3