0

I am new in Angular What I am going to try is to get the HTML of a page and reproduce it into an iFrame (it is an exercise). I am using the following piece of code:

    var prova = this._http.get(myUrl, {responseType: "text"}).subscribe((x) =>{
  console.log(x);
});

I did it on a website (if is needed I can also insert the name of the pages) and it returns the html only of some pages. In the other case the string x is empty. Could it depend on connection? Or there is some way to wait the end of the get request? Or simply is wrong my approach and I should make a different type of request?

4
  • Is myUrl a static html page? Commented Jun 21, 2018 at 18:13
  • no are list and product pages of an ecommerce Commented Jun 22, 2018 at 11:23
  • Your going to run into various issues due to java script not executing on the page you are trying to get. I would suggesting test your code on a static web page first. Commented Jun 22, 2018 at 12:35
  • tried on static webpages and it works. If your supposition is right what could I do? could be a request header problem ? Commented Jun 22, 2018 at 12:45

1 Answer 1

1

Your most likely going to need to use a library like puppeteer if you want to render a page properly. Puppeteer is a node library and useless headless chrome so I am not sure how well you could really integrate with Angular.

https://github.com/GoogleChrome/puppeteer

Sign up to request clarification or add additional context in comments.

1 Comment

ok I'll try to integrate the library in my project (I think is enough to add as "script" into angular.json). Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.