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

Chap03
Yiqing Zhu 2022-03-26 14:39:21 +11:00
parent 072b7dcf88
commit cdecba7c2e
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))
}