Last active
August 7, 2024 15:08
-
-
Save andresgallo/5ad313b4d74b14c1466a985d28823a87 to your computer and use it in GitHub Desktop.
Fetch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const url = this.getAttribute('data-url') | |
fetch(url) | |
.then(function(response) { | |
return response.text() | |
}) | |
.then(function(html) { | |
var parser = new DOMParser(); | |
var doc = parser.parseFromString(html, "text/html"); | |
console.log('HEREEEE', doc); | |
// this.innerHTML = doc.documentElement.innerHTML | |
}) | |
.catch(function(err) { | |
console.log('Failed to fetch page: ', err); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
((url) => { | |
fetch(url) | |
.then(function(response) { | |
return response.text() | |
}) | |
.then(function(html) { | |
var parser = new DOMParser(); | |
var doc = parser.parseFromString(html, "text/html"); | |
console.log('HEREEEE', doc); | |
// this.innerHTML = doc.documentElement.innerHTML | |
}) | |
.catch(function(err) { | |
console.log('Failed to fetch page: ', err); | |
}); | |
})('somepage.html') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment