Question about getResourceFromContext and getResourceCollectionFromContext
See original GitHub issueHi,
I try to use getResourceFromContext and getResourceCollectionFromContext, are there supposed to do the same thing ?
For example, i want to retrieve a specific node by nid. With getResourceCollectionFromContext, this is fine, i get an array with the node in it.
const node = await drupal.getResourceCollectionFromContext<DrupalNode[]>("node--page", context, {
params: getParams("node--page").addFilter("nid", "2").getQueryObject(),
})
but if i do the same thing with getResourceFromContext, i got null response
const node = await drupal.getResourceFromContext<DrupalNode>("node--page", context, {
params: getParams("node--page").addFilter("nid", "2").getQueryObject(),
})
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top Results From Across the Web
getResourceCollectionFromCont...
getResourceCollectionFromContext. Fetch a collection of resources from getStaticProps or getServerSideProps context.
Read more >Decoupled Drupal with Next.JS using Next-Drupal - Axelerant
The primary methods that we used to get data in our application are getResourceCollectionFromContext and getResourceFromContext.
Read more >How to progressively decouple your Drupal site with Next.js ...
getResourceCollectionFromContext is a helper function from next-drupal. ... getResourceFromContext(path, context, { params: new ...
Read more >Next.js on Acquia: Customizing content types
import { getResourceCollectionFromContext } from "next-drupal" import ... node = await getResourceFromContext<DrupalNode>(type, context, ...
Read more >next-drupal - bytemeta
Question about getResourceFromContext and getResourceCollectionFromContext. Transformative-JY. Transformative-JY OPEN.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah a
getResourceCollection
with afilter
should do the trick.Yes I saw that but sometimes I need to use a
nid
😃 i’ll do with collection it works fine 😉I just can’t manage to get the node by slug / alias with
getResourceFromContext
which is weird 😃Thank you anyway for your answers and Work on this ! For now i manage to do what i want with this module !