How to use Observable to read another javascript file

0

In the company I work for I am forced to deal with some gambiarras and this is one more of them.

It is as follows. I have an application in Angular 6 and I need to get the data from a .js file which is on a server that I do not have access to. The problem is that these data are declared as variables and I'm using HttpClient to make the request. The file I have to read is this way

var usuario = 'nomedousuário';
var descricao = 'descrição do usuário';

in the user.service the request is made like this:

getProfile(username) {
let profileLocation = 'http://exemplo.com/{username}/profile.js';

publicProfileLocation = publicProfileLocation.replace(/{user}/, username);

return this._http.get(publicProfileLocation).map(
  res => {
     // como tratar esse arquivo?

  }
);
}

Well, does anyone know the best way to handle this file?

How do I, for example, read the file as a string, then use split, replace etc to turn it into a json?

When I give a console.log in the subscribe of the response, it always returns the error.

    
asked by anonymous 02.07.2018 / 06:49

0 answers