Skip to content

Commit 4d27b15

Browse files
committed
docs: add reference examples for deserialize
1 parent ace7dac commit 4d27b15

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/next-drupal/src/next-drupal.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,20 @@ export class NextDrupal extends NextDrupalBase {
12781278
* @param {any} body The response body.
12791279
* @param {any} options Options for deserialization.
12801280
* @returns {any} The deserialized response body.
1281+
* @remarks
1282+
* To provide your own custom deserializer, see the serializer docs.
1283+
* @example
1284+
* ```ts
1285+
* const url = drupal.buildUrl("/jsonapi/node/article", {
1286+
* sort: "-created",
1287+
* "fields[node--article]": "title,path",
1288+
* })
1289+
*
1290+
* const response = await drupal.fetch(url.toString())
1291+
* const json = await response.json()
1292+
*
1293+
* const resource = drupal.deserialize(json)
1294+
* ```
12811295
*/
12821296
deserialize(body, options?) {
12831297
if (!body) return null

0 commit comments

Comments
 (0)