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

Different way to implement environment variables #8

Open
in28minutes opened this issue Aug 3, 2021 · 1 comment
Open

Different way to implement environment variables #8

in28minutes opened this issue Aug 3, 2021 · 1 comment

Comments

@in28minutes
Copy link
Owner

cool. Here is my code for environment.ts, as a suggestion:

export const environment = {
production: false,
api: {
url: 'http://localhost:8585',
jpa: 'http://localhost:8585/jpa',
},
};
of course, the port for your setup will not stay 8585, so feel free to adapt it heavily ;-)

You basically use it in two places, basic-authentication.service and todo-data.service. In basic there is only one instance, in todo-data a couple, so I am just posting a few lines of todo-date as an example. In your version I sort of like that it uses all UPPERCASE because those are constants. This is not the way environment.ts is implemented, though, so you would have to live with lowercase:

import { environment } from 'src/environments/environment';

...

export class TodoDataService {
...
retrieveAllTodos(username) {
return this.http.get<Todo[]>(${environment.api.jpa}/users/${username}/todos);
...
}
...
}

@in28minutes
Copy link
Owner Author

https://www.udemy.com/course/full-stack-application-development-with-spring-boot-and-angular/learn/#questions/15703804/

For what it's worth, here is my environment.ts:

// This file can be replaced during build by using the fileReplacements array.
// ng build --prod replaces environment.ts with environment.prod.ts.
// The list of file replacements can be found in angular.json.

export const environment = {
production: false,
api: {
url: 'http://localhost:8585',
jpa: 'http://localhost:8585/jpa',
},
};

/*

  • For easier debugging in development mode, you can import the following file
  • to ignore zone related error stack frames such as zone.run, zoneDelegate.invokeTask.
  • This import should be commented out in production mode because it will have a negative impact
  • on performance if an error is thrown.
    */
    // import 'zone.js/dist/zone-error'; // Included with Angular CLI.
    Lemme know if I can be of more help. Note that I have the tomcat configured to run on 8585 because 8080 is used by my local Jira.

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

1 participant