Skip to content

Commit

Permalink
feat: Dummy data for project
Browse files Browse the repository at this point in the history
  • Loading branch information
VibrantCarl committed May 26, 2020
1 parent 24cb06f commit c09b588
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions utils/_DATA.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { AsyncStorage } from "react-native";

const dummyData = {
React: {
title: "React",
questions: [
{
question: "What is React?",
answer: "A library for managing user interfaces"
},
{
question: "Where do you make Ajax requests in React?",
answer: "The componentDidMount lifecycle event"
}
]
},
JavaScript: {
title: "JavaScript",
questions: [
{
question: "What is a closure?",
answer:
"The combination of a function and the lexical environment within which that function was declared."
}
]
}
};

export const STORAGE_KEY = "UdaciCard:StorageKey";

function setDummyData() {
AsyncStorage.setItem(STORAGE_KEY, JSON.stringify(dummyData));
return dummyData;
}

export function fetchData(results) {
return results === null ? setDummyData() : JSON.parse(results);
}

0 comments on commit c09b588

Please sign in to comment.