How to generate my PostgreSQL BaseURL (link) that is in Heroku to integrate with my Angular front end?

1

My question is: how do I generate the link (baseurl) so that my front-end accesses the data coming from that database (PostgreSQL) > Heroku ?

My PostgreSQL there from Heroku releases this information:

As img above I have host , database and etc., now I need to put some information like this here in that part of my front- / em> (Service) eventosUrl = '???'; to release the data coming from bd Heroku:

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

@Injectable()
export class EventoService {

//eventosUrl = 'http://localhost:8080/eventos';
eventosUrl = '???';

constructor(private http: HttpClient) { }

listar() {
  return this.http.get<any[]>(this.eventosUrl);
  }
}

I do not know if I need to put something in my application.properties file since I locally put it to release access to the database via Ajax (requests):

ARCHIVE application.properties:

origem-permitida=http://localhost:4200
    
asked by anonymous 09.05.2018 / 14:53

1 answer

1

creates a configuration file with the following content:

export const API_CONFIG = {
     baseUrl: "https://nome-do-app.herokuapp.com",
}

In each service vc you import this file and in the methods that communicate with api vc puts it this way:

return this.http.get<Objeto[]>('${API_CONFIG.baseUrl}/nome-da-rota');

That way, if you ever change from link to link , you only change in the configuration file and you do not need to tinker with nhm service.

    
09.05.2018 / 23:57