Methods

This section describes methods of the EndpointSelector object.

urlFor(key)

Returns a local or a productional URL depending on how the application is currently running.

Parameters:
key: String
The name of the local/productional URLs pair that is defined in the EndpointSelector's configuration object.
Return Value: String
The local or productional URL of the specified URL pair, depending on how the application is currently running.

To retrieve a local or productional URL, the urlFor method uses the configuration object passed to the EndpointSelector object constructor.

JavaScript
Application1.config.endpoints: {
    variant1: {
        local: "",
        production: ""
    },
    variant2: {
        local: "",
        production: ""
    },
    ...
}

Pass the name of the links pair as the parameter of the urlFor method and the local URL will be returned if the application is currently running on a local host, otherwise the productional URL will be returned.

This method can be used to get a link to the data source that is different for the locally running application and the application that runs on production.