File tree 2 files changed +10
-2
lines changed
examples/example-router-migration/app/[...slug]
starters/basic-starter/app/[...slug] 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[]) {
12
12
13
13
const params : JsonApiParams = { }
14
14
15
+ const isDraftMode = draftMode ( ) . isEnabled
15
16
const draftData = getDraftData ( )
16
17
17
18
if ( draftData . path === path ) {
18
19
params . resourceVersion = draftData . resourceVersion
19
20
}
20
21
21
22
// 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
+ } )
23
26
24
27
if ( ! translatedPath ) {
25
28
throw new Error ( "Resource not found" , { cause : "NotFound" } )
@@ -34,6 +37,7 @@ async function getNode(slug: string[]) {
34
37
35
38
const resource = await drupal . getResource < DrupalNode > ( type , uuid , {
36
39
params,
40
+ withAuth : isDraftMode ,
37
41
} )
38
42
39
43
if ( ! resource ) {
Original file line number Diff line number Diff line change @@ -12,14 +12,17 @@ async function getNode(slug: string[]) {
12
12
13
13
const params : JsonApiParams = { }
14
14
15
+ const isDraftMode = draftMode ( ) . isEnabled
15
16
const draftData = getDraftData ( )
16
17
17
18
if ( draftData . path === path ) {
18
19
params . resourceVersion = draftData . resourceVersion
19
20
}
20
21
21
22
// 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
+ } )
23
26
24
27
if ( ! translatedPath ) {
25
28
throw new Error ( "Resource not found" , { cause : "NotFound" } )
@@ -34,6 +37,7 @@ async function getNode(slug: string[]) {
34
37
35
38
const resource = await drupal . getResource < DrupalNode > ( type , uuid , {
36
39
params,
40
+ withAuth : isDraftMode ,
37
41
} )
38
42
39
43
if ( ! resource ) {
You can’t perform that action at this time.
0 commit comments