File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
examples/example-router-migration/app/[...slug]
starters/basic-starter/app/[...slug] Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -12,14 +12,17 @@ async function getNode(slug: string[]) {
1212
1313 const params : JsonApiParams = { }
1414
15+ const isDraftMode = draftMode ( ) . isEnabled
1516 const draftData = getDraftData ( )
1617
1718 if ( draftData . path === path ) {
1819 params . resourceVersion = draftData . resourceVersion
1920 }
2021
2122 // Translating the path also allows us to discover the entity type.
22- const translatedPath = await drupal . translatePath ( path )
23+ const translatedPath = await drupal . translatePath ( path , {
24+ withAuth : isDraftMode ,
25+ } )
2326
2427 if ( ! translatedPath ) {
2528 throw new Error ( "Resource not found" , { cause : "NotFound" } )
@@ -34,6 +37,7 @@ async function getNode(slug: string[]) {
3437
3538 const resource = await drupal . getResource < DrupalNode > ( type , uuid , {
3639 params,
40+ withAuth : isDraftMode ,
3741 } )
3842
3943 if ( ! resource ) {
Original file line number Diff line number Diff line change @@ -12,14 +12,17 @@ async function getNode(slug: string[]) {
1212
1313 const params : JsonApiParams = { }
1414
15+ const isDraftMode = draftMode ( ) . isEnabled ;
1516 const draftData = getDraftData ( )
1617
1718 if ( draftData . path === path ) {
1819 params . resourceVersion = draftData . resourceVersion
1920 }
2021
2122 // Translating the path also allows us to discover the entity type.
22- const translatedPath = await drupal . translatePath ( path )
23+ const translatedPath = await drupal . translatePath ( path , {
24+ withAuth : isDraftMode ,
25+ } )
2326
2427 if ( ! translatedPath ) {
2528 throw new Error ( "Resource not found" , { cause : "NotFound" } )
@@ -34,6 +37,7 @@ async function getNode(slug: string[]) {
3437
3538 const resource = await drupal . getResource < DrupalNode > ( type , uuid , {
3639 params,
40+ withAuth : isDraftMode ,
3741 } )
3842
3943 if ( ! resource ) {
You can’t perform that action at this time.
0 commit comments