getEntryForResourceType
Get the JSON:API entry for a resource type.
const url = await drupal.getEntryForResourceType(type, locale?): Promise<string>
type: string
- Required
- The resource type. Example:
node--article
.
locale: string
- Optional
- The locale to fetch the index. Example:
es
orfr
.
Notes
By default, when retrieving resources in getResource
or getResourceCollection
, the DrupalClient
make a request to Drupal to fetch the JSON:API resource entry..
Example: if you provide node--article
, DrupalClient
will make a request to http://example.com/jsonapi/node/article
.
If you would like to infer the entry from the resource type, use the useDefaultResourceTypeEntry
option.
const drupal = new DrupalClient(process.env.NEXT_PUBLIC_DRUPAL_BASE_URL, { useDefaultResourceTypeEntry: true,})
Examples
// https://example.com/jsonapi/node/article.const url = await drupal.getEntryForResourceType(`node--article`)