DevExtreme React - EndpointSelector Methods

This section describes methods that control an EndpointSelector instance.

urlFor(key)

Gets an endpoint with a specific key.

Parameters:
key:

String

The endpoint's key.

Return Value:

String

The endpoint.

App.js
  • // ...
  • import EndpointSelector from 'devextreme/data/endpoint_selector';
  •  
  • const endpointSelector = new EndpointSelector({
  • db1: {
  • local: 'http://localhost:55555/service1.svc/',
  • production: 'http://services.example.com/service1.svc/'
  • },
  • db2: {
  • local: 'http://localhost:55555/service2.svc/',
  • production: 'http://services.example.com/service2.svc/'
  • },
  • // ...
  • });
  •  
  • class App extends React.Component {
  • constructor(props) {
  • super(props);
  •  
  • // Logs http://localhost:55555/service1.svc/ or http://services.example.com/service1.svc/
  • // depending on whether the app's local or deployed version is running
  • console.log(endpointSelector.urlFor('db1'));
  • }
  • }
  • export default App;