File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -1147,9 +1147,33 @@ export class NextDrupal extends NextDrupalBase {
11471147 /**
11481148 * Fetches a view by its name.
11491149 *
1150- * @param {string } name The name of the view.
1150+ * @param {string } name The name of the view and the display id. Example: `articles--promoted` .
11511151 * @param {JsonApiOptions & JsonApiWithNextFetchOptions } options Options for the request.
11521152 * @returns {Promise<DrupalView<T>> } The fetched view.
1153+ * @requires JSON:API Views module
1154+ * @example
1155+ * Get a view named `articles` and display id `promoted`
1156+ * ```ts
1157+ * const view = await drupal.getView("articles--promoted")
1158+ * ```
1159+ *
1160+ * Using sparse fieldsets to only fetch the title and body fields
1161+ * ```ts
1162+ * const view = await drupal.getView("articles--promoted", {
1163+ * params: {
1164+ * fields: {
1165+ * "node--article": "title,body",
1166+ * },
1167+ * },
1168+ * })
1169+ * ```
1170+ *
1171+ * Using TypeScript with DrupalNode for a node entity type
1172+ * ```ts
1173+ * import { DrupalNode } from "next-drupal"
1174+ *
1175+ * const view = await drupal.getView<DrupalNode>("articles--promoted")
1176+ * ```
11531177 */
11541178 async getView < T = JsonApiResource > (
11551179 name : string ,
You can’t perform that action at this time.
0 commit comments