Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to load config variable #743

Closed
ShurikAg opened this issue Apr 8, 2016 · 2 comments
Closed

Failing to load config variable #743

ShurikAg opened this issue Apr 8, 2016 · 2 comments

Comments

@ShurikAg
Copy link

ShurikAg commented Apr 8, 2016

Hi all,

I am trying to read config variable from that I defined in project config but browser complains about mot finding the config file.
In the project.config.ts :

export class ProjectConfig extends SeedConfig {
  BACKEND_BASE_URL = argv['backend_base_url'] || 'http://localhost:8080';

And in one of my service classes I have:

import {BACKEND_BASE_URL} from '../../../tools/config';  // Yes, it is a valid pass
...
return this.http.post(BACKEND_BASE_URL + '/api/login', body, options).toPromise()
...

The browser tries to pull it as http://localhost:3000/tools/config.js and of course failing with 404.
Is it even supported?

@mgechev
Copy link
Owner

mgechev commented Apr 9, 2016

project.config.ts is only for tooling configuration.

You need to define this constant inside of the src directory in order to make it accessible by the rest of the app:

// src/config.ts
export constant BACKEND_BASE_URL = '<%= BACKEND_BASE_URL %>';

This way the value of the constant BACKEND_BASE_URL, which is defined in project.config.ts will be interpolated within the rest of the code inside src/config.ts.

@mgechev mgechev closed this as completed Apr 9, 2016
@ShurikAg
Copy link
Author

ShurikAg commented Apr 9, 2016

Thank you, Sir!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants