URLs.format()

Build a URL from a template string and a set of route parameters.

Template is in the standard express/backbone format.

Usage

Hover over inputs/exits for more info.

var URLs = require('machinepack-urls');


// Build a URL from a template string and a set of route parameters.

URLs.format({

urlTemplate: '/api/v1/user/:id/friends/:friendId',

data: {},

}).execSync();

Inputs

urlTemplate required

The URL template, consisting of zero or more colon-prefixed tokens.

'/api/v1/user/:id/friends/:friendId'
data required

An object of key/value pairs to use as url path parameter values.

{}

Exits

error

An unexpected error occurred.

success

OK.

'/api/v1/user/7/friends/aba213-a83192bf-d139-e139e'