Is it possible to save the HTML Code from an URL?
opened this issue · comments
Is there a way to save html code of an URL?
So that I can request this HTML-Code from store.get() and to view it in a WebView?
I'm sure there is a way to do that. How is the HTML defined? Separate HTML file? Template literal?
It is just a normal HTML Website, like Google or bettet dribbble.com.
It contains Images and normal Elements like DIVs or something like that.
Am 26.07.2016 um 05:29 schrieb Jason Merino notifications@github.com:
I'm sure there is a way to do that. How is the HTML defined? Separate HTML file? Template literal?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
So you are looking to request HTML from a URL from your app and save that to AsyncStorage?
Yes that is right!
Okay, I just played around with this enough to get it to work. Here's what I came up with.
import store from 'react-native-simple-store';
fetch('http://google.com')
// return the res.text() to get the body of the request
.then((res) => res.text())
.then((body) => {
store
.save('google', body)
// just for verification get the value for the key 'google' in simple store
.then(() => store.get('google'))
.then((value) => {
// value is the markup for the google page
});
});
Closing this now, but if you have more questions feel free to comment again.