-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #167 from starboardcoop/0.2.0
0.2.0
- Loading branch information
Showing
21 changed files
with
92 additions
and
454 deletions.
There are no files selected for viewing
This file contains 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
async function getAll() { | ||
let data; | ||
let now = new Date(); | ||
|
||
let previousRefresh = new Date(localStorage.getItem("previousRefresh")); | ||
if (Math.abs(now - previousRefresh) > 120000) { | ||
data = _getAll(); | ||
localStorage.setItem("previousRefresh", now.toUTCString()); | ||
} else { | ||
data = JSON.parse(localStorage.getItem("data")); | ||
|
||
console.log('Previous data refreshed.'); | ||
} | ||
|
||
return data; | ||
} | ||
|
||
async function _getAll() { | ||
const result = await fetch(`/.netlify/functions/things`); | ||
let data = await result.json(); | ||
localStorage.setItem("data", JSON.stringify(data)); | ||
|
||
console.log('Refreshed data from API.'); | ||
return data; | ||
} | ||
|
||
export default { | ||
getAll | ||
} |
This file contains 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.