Takes a Resource object and returns its path as a string, with any path parameters replaced with their corresponding values. Optionally, it can ensure that the returned URL has a trailing slash.
Resource
const resource = { path: 'users/{id}/messages', params: { id: 1 },};getUrlFromResource(resource, false); // 'users/1/messages'getUrlFromResource(resource, true); // 'users/1/messages/' Copy
const resource = { path: 'users/{id}/messages', params: { id: 1 },};getUrlFromResource(resource, false); // 'users/1/messages'getUrlFromResource(resource, true); // 'users/1/messages/'
A string literal representing the path template with placeholders.
The Resource object containing the path and parameters.
Optional
If true, the returned URL will have a trailing slash.
true
The URL with all placeholders replaced by the corresponding values from params.
params
Takes a
Resource
object and returns its path as a string, with any path parameters replaced with their corresponding values. Optionally, it can ensure that the returned URL has a trailing slash.Example