Skip to content

Instantly share code, notes, and snippets.

@Comandeer
Created July 7, 2018 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Comandeer/2d2e442b0c89b6173cc085d5e6948f52 to your computer and use it in GitHub Desktop.
Save Comandeer/2d2e442b0c89b6173cc085d5e6948f52 to your computer and use it in GitHub Desktop.
Using DOMParser
return fetch( URL ).then( ( response ) => {
return response.text();
} ).then( ( html ) => {
const parser = new DOMParser(); // 1
return parser.parseFromString( html, 'text/html' ); // 2
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment