localForage/examples/index.html
Matthew Riley MacPherson f6247df6f4 Update to use promises
2014-01-20 23:44:01 -05:00

29 lines
753 B
HTML

<!doctype html>
<html>
<head>
<meta charset="utf8" />
<title>Simple localForage example</title>
</head>
<body>
<script src="../dist/localForage.js"></script>
<script>
var key = 'STORE_KEY';
var value = 'What we save offline';
var UNKNOWN_KEY = 'unknown_key';
localForage.setItem(key, value, function() {
console.log('Saved: ' + value);
localForage.getItem(key, function(readValue) {
console.log('Read: ', readValue);
});
});
// Since this key hasn't been set yet, we'll get a null value
localForage.getItem(UNKNOWN_KEY, function(readValue) {
console.log('Result of reading ' + UNKNOWN_KEY, readValue);
});
</script>
</body>
</html>