0

I have a html page stored remotely, How can I access using Reactjs ? if I can able to access then how I can parse that page and render in browser ? can any one faced this kind of challenge, please let me know the solutions if you found.

Thank you.

2 Answers 2

1

You can use the fetch API to download and render the page.

    fetch("http://www.example.com/home.html") 
.then((response) => response.text())
.then((html) => { document.getElementById("content").innerHTML = html; })
.catch((error) => { console.warn(error); });
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the response, but it wont work as i was tried.
0

Fetching can be done with fetch("http://example.com/path/to/file.html") - this returns a Promise.

If you want to use the fetched html page inside of react, you can fetch it, save it in the state and then render it using the dangerouslySetInnerHTML property on a div - check out this codesandbox example.

Comments

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.