Documentation / @ember-data/request-utils / index / buildBaseURL
Function: buildBaseURL()
ts
function buildBaseURL(urlOptions): string;Defined in: warp-drive-packages/utilities/declarations/index.d.ts:164
Builds a URL for a request based on the provided options. Does not include support for building query params (see buildQueryParams) so that it may be composed cleanly with other query-params strategies.
Usage:
ts
import { buildBaseURL } from '@ember-data/request-utils';
const url = buildBaseURL({
host: 'https://api.example.com',
namespace: 'api/v1',
resourcePath: 'emberDevelopers',
op: 'query',
identifier: { type: 'ember-developer' }
});
// => 'https://api.example.com/api/v1/emberDevelopers'On the surface this may seem like a lot of work to do something simple, but it is designed to be composable with other utilities and interfaces that the average product engineer will never need to see or use.
A few notes:
resourcePathis optional, but if it is not provided,identifier.typewill be used.hostandnamespaceare optional, but if they are not provided, the values globally configured viasetBuildURLConfigwill be used.opis required and must be one of the following:- 'findRecord' 'query' 'findMany' 'findRelatedCollection' 'findRelatedRecord'` 'createRecord' 'updateRecord' 'deleteRecord'
- Depending on the value of
op,identifieroridentifierswill be required.
Parameters
urlOptions
Returns
string