Chap03 -> Implementing component state (Change getUnansweredQuestions to async function, result failure in transpiling)

master
Jason Zhu 2022-03-26 14:39:21 +11:00
parent 5d7f817620
commit de5bc7f437
1 changed files with 6 additions and 1 deletions

View File

@ -48,6 +48,11 @@ const questions: QuestionData[] = [
},
];
export const getUnansweredQuestions = (): QuestionData[] => {
export const getUnansweredQuestions = async(): Promise<QuestionData[]> => {
await wait(500);
return questions.filter((q) => q.answers.length === 0);
};
const wait = (ms: number): Promise<void> => {
return new Promise(resolve => setTimeout(resolve, ms))
}