-2

I'm pulling a base64 encoded image from a server to a website and want to automatically use the image. The image comes within an object file and I'm not sure how to extract just the image from the object.

Server send the object using (Node.js server):

res.send(result[0]);

The website get request and display code:

getImage() {
this.httpClient.get('http://ip_address/route/imagename')
  .subscribe(data => {
    this.getImg = data;
    console.log(data);
  });

The result is an object containing the image, but I want the image to display on its own, outside of the object. I don't know if that needs happens on the server, or on the website, but i dont know either way.. console log image on website link

Ben Shan
  • 9
  • 4

1 Answers1

0

I needed to save the data file to a variable then save it to a different variable, specifying the part I wanted in the first variable. Like:

this.httpClient.get('ip_address/images/' + imgName)
  .subscribe(data => {
    this.imageData = data;
    this.base64image = (this.imageData.image);

this.base64image can then be used as the base64 code.

Ben Shan
  • 9
  • 4