December 2019
Intermediate to advanced
598 pages
12h 21m
English
Let's use our http function to get a single question from our REST API:
export const getQuestion = async ( questionId: number,): Promise<QuestionData | null> => { // TODO - make the request // TODO - return null if the request fails or there is a network error // TODO - return response body with correctly typed dates if request is successful};
export const getQuestion = async ( questionId: number,): Promise<QuestionData | null> => { try { const result = await http<undefined, QuestionDataFromServer>({ path: `/questions/${questionId}`, }); ...Read now
Unlock full access