updateResource
Update a resource.
const resource = await drupal.updateResource<T = JsonApiResource>( type, uuid, body, options?: { params, withAuth, deserialize, }): Promise<T>type: string- Required
- The resource type. Example:
node--article,taxonomy_term--tags, orblock_content--basic.
uuid: string- Required
- The resource id. Example
a50ffee7-ba94-46c9-9705-f9f8f440db94.
body: JsonApiUpdateResourceBody- Required
- The body payload with
data.
options- Optional
params: JsonApiParams: JSON:API params such asfilter,fields,includeorsort.withAuth: boolean | NextDrupalAuth:- Set the authentication method to use. See the authentication docs.
- Set to
trueto use the authentication method configured on the client.
deserialize: boolean: Set to false to return the raw JSON:API response.
Examples
- Update a
node--pageresource.
const page = await drupal.updateResource( "node--page", "a50ffee7-ba94-46c9-9705-f9f8f440db94", { data: { attributes: { title: "Updated Title", }, }, })TypeScript
- Using
DrupalNodefor a node entity type.
import { DrupalNode } from "next-drupal"
const page = await drupal.updateResource<DrupalNode>( "node--page", "a50ffee7-ba94-46c9-9705-f9f8f440db94", { data: { attributes: { title: "Updated Title", }, }, })See the TypeScript docs for more built-in types.