fetch
A wrapper for the polyfilled fetch.
const response = await drupal.fetch(input, init?): Promise<Response>
input: RequestInfo
- Required
- The url to fetch from.
init: FetchOptions
- Optional
- The fetch options with
withAuth
. - If
withAuth
is set,fetch
will fetch anAuthorization
header before making the request.
Notes
- To provide your own custom fetcher, see the fetcher docs.
Examples
const url = drupal.buildUrl("/jsonapi/node/article", { sort: "-created", "fields[node--article]": "title,path",})
const response = await drupal.fetch(url.toString())