File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -20,20 +20,26 @@ exports.sourceNodes = async (
2020 const {
2121 baseUrl,
2222 apiBase = "jsonapi" ,
23- basicAuth,
24- headers,
23+ basicAuth = { } ,
24+ headers = { } ,
2525 menus,
2626 } = pluginOptions
2727 const { createNode, createParentChildLink } = actions
2828
2929 reporter . info ( `Starting to fetch menu link items from Drupal` )
3030 reporter . info ( "Menus to fetch are " + menus . join ( ", " ) )
3131
32+ if ( basicAuth . username ) {
33+ headers . Authorization = `Basic ${ Buffer . from (
34+ `${ basicAuth . username } :${ basicAuth . password } ` ,
35+ "utf-8"
36+ ) . toString ( "base64" ) } `
37+ }
38+
3239 // Data can come from anywhere, but for now create it manually
3340 const menuResponses = await Promise . all (
3441 menus . map ( async ( menu ) => {
3542 return await fetch ( `${ baseUrl } /${ apiBase } /menu_items/${ menu } ` , {
36- auth : basicAuth ,
3743 headers,
3844 } ) . then ( function ( response ) {
3945 if ( response . status >= 400 ) {
You can’t perform that action at this time.
0 commit comments