Instantiates a new NextDrupalBase.
const client = new NextDrupalBase(baseUrl)
The baseUrl of your Drupal site. Do not add the /jsonapi suffix.
Options for NextDrupalBase.
OptionalaccessOptionalfetcherOptionalinit: RequestInitAdds a locale prefix to the given path.
The path.
The options for adding the locale prefix.
OptionaldefaultLocale?: stringThe default locale.
Optionallocale?: stringThe locale.
The path with the locale prefix.
Builds an endpoint URL with the given options.
The options for building the endpoint.
Optionallocale?: stringThe locale.
Optionalpath?: stringThe path.
OptionalsearchParams?: EndpointSearchParamsThe search parameters.
The constructed endpoint URL.
Builds a URL with the given path and search parameters.
The path for the url. Example: "/example"
OptionalsearchParams: EndpointSearchParamsOptional query parameters.
The constructed URL.
const drupal = new DrupalClient("https://example.com")
// https://drupal.org
drupal.buildUrl("https://drupal.org").toString()
// https://example.com/foo
drupal.buildUrl("/foo").toString()
// https://example.com/foo?bar=baz
client.buildUrl("/foo", { bar: "baz" }).toString()
Build a URL from DrupalJsonApiParams
const params = {
getQueryObject: () => ({
sort: "-created",
"fields[node--article]": "title,path",
}),
}
// https://example.com/jsonapi/node/article?sort=-created&fields%5Bnode--article%5D=title%2Cpath
drupal.buildUrl("/jsonapi/node/article", params).toString()
Constructs a path from the given segment and options.
The path segment.
The options for constructing the path.
OptionaldefaultLocale?: stringThe default locale.
Optionallocale?: stringThe locale.
OptionalpathPrefix?: stringThe path prefix.
The constructed path.
Fetches a resource from the given input URL or path.
The url to fetch from.
The fetch options with withAuth.
If withAuth is set, fetch will fetch an Authorization header before making the request.
The fetch response.
Retrieve an access token.
OptionalclientIdSecret: NextDrupalAuthClientIdSecretThe client ID and secret.
The access token.
Gets the authorization header value based on the provided auth configuration.
The auth configuration.
The authorization header value.
Extracts errors from the fetch response.
The fetch response.
The extracted errors.
The base class for NextDrupal clients.