Configuring the Base Server URL

Create a new file named baseurl.ts in the shared folder and update its contents as follows:

export const baseURL = 'http://localhost:3000/';

Note the export of the constant named baseURL which is set to http://localhost:3000. Recall that this is the base URL at which the JSON server is accessible.

Import baseURL and update the AppModule's providers property of the @NgModule decorator as follows:

...
import { baseURL } from './shared/baseurl';
...
@NgModule({
...
providers: [...
LeaderService,
{provide: 'BaseURL', useValue: baseURL}],
...

Angular provides a way of supplying values to the rest of the application by configuring a provider within your app module.

Note the import of { baseURL } from './shared/baseurl';

This value can now be made available to the rest of the application by going to the providers and adding {provide: 'BaseURL', useValue: baseURL}],