1.0.11 • Published 1 year ago

@jwelfare/gathercontent-utils v1.0.11

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

@jwelfare/gathercontent-utils

Helpful util functions for working with the GatherContent API

Usage

contentify(item)

Recursively converts a GatherContent item response to a friendly content object by 'slugifying' it's labels into properities.

Params

NameTypeDescription
itemGatherContentItemthe item object to contentify

Example

import { contentify } from '@jwelfare/gathercontent-utils';

const response = await fetch(`https://api.gathercontent.com/items/${itemId}?include=structure`, {
  Accept: 'application/vnd.gathercontent.v2+json',
  Authorization: `Basic ${base64credentials}`,
});
// {
//   "data": {
//     ...
//     "content": {
//       "9f6a25b8-7617-495d-9c5c-7ef05ed68cf6": "<p>More features coming soon. This will include the ability to request COVID-19 vaccination certificates.</p>"
//     },
//     "structure": {
//       "uuid": "d6bf5b9b-a224-4283-84f7-4a02baa8b5aa",
//       "groups": [
//         {
//           "uuid": "19dfab8d-a533-4e52-b5c5-7acf3fadc4df",
//           "name": "Content",
//           "fields": [
//             {
//               "uuid": "9f6a25b8-7617-495d-9c5c-7ef05ed68cf6",
//               "label": "Hello World",
//               ...
//             }
//           ]
//         }
//       ]
//     }
//   }
// }

const content = contentify(response.data);
// {
//   'helloWorld': "<p>More features coming soon. This will include the ability to request COVID-19 vaccination certificates.</p>"
// }

Acknowledgements

Based off code within GatherContent's offical client.

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago