File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -431,9 +431,32 @@ export class NextDrupal extends NextDrupalBase {
431431 /**
432432 * Fetches a resource of the specified type by its path.
433433 *
434- * @param {string } path The path of the resource.
435- * @param {JsonApiOptions & JsonApiWithNextFetchOptions } options Options for the request.
434+ * @param {string } path The path of the resource. Example: `/blog/slug-for-article`.
435+ * @param { { isVersionable?: boolean } & JsonApiOptions & JsonApiWithNextFetchOptions } options Options for the request.
436+ * - isVersionable: Set to true if you're fetching the revision for a resource. Automatically set to true for node entity types
436437 * @returns {Promise<T> } The fetched resource.
438+ * @requires Decoupled Router module
439+ * @example
440+ * Get a page by path
441+ * ```
442+ * const node = await drupal.getResourceByPath("/blog/slug-for-article")
443+ * ```
444+ * Get the raw JSON:API response
445+ * ```
446+ * const { data, meta, links } = await drupal.getResourceByPath(
447+ * "/blog/slug-for-article",
448+ * {
449+ * deserialize: false,
450+ * }
451+ * )
452+ *```
453+ * Using DrupalNode for a node entity type
454+ * ```
455+ * import { DrupalNode } from "next-drupal"
456+ * const node = await drupal.getResourceByPath<DrupalNode>(
457+ * "/blog/slug-for-article"
458+ * )
459+ * ```
437460 */
438461 async getResourceByPath < T extends JsonApiResource > (
439462 path : string ,
You can’t perform that action at this time.
0 commit comments