I am trying to place my connection string for an API in a .env file. My API is running off of localhost. My projects consist of microservices, so the frontend is running off of one port while the API is running off of a different port. I have installed dotenv. Below is the code, any and all help would be greatly appreciated!
This code is running on port 3000
Services
class TestService {
private TEST_RESOURCE = this.$resource(process.env.TEST_PORT);
constructor(private $resource){}
public getAll(){
return this.TEST_RESOURCE.query();
}
.env
TEST_PORT=http://localhost:8080/api/v1/weightclasses
app.ts (node)
require('dotenv').config({silent: true})
I was thinking that maybe there is something with localhost not being able to be used in .env as I have been playing with this for sometime. Any help would be greatly appreciated! If any other code or info is needed please let me know. I am not getting any errors in the console and the network tab is not showing anything either.
What works is the following code, but I would like to be able to use dotenv.
class TestService {
private TEST_RESOURCE = this.$resource("http://localhost:8080/api/v1/weightclasses");
constructor(private $resource){}
public getAll(){
return this.TEST_RESOURCE.query();
}
Thank you.
via bemon
No comments:
Post a Comment