Getting unanswered questions from the REST API

We are going to start interacting with the REST API on the home page when displaying the list of unanswered questions. The HomePage component won't actually change, but the getUnansweredQuestions function in QuestionsData.ts will. In getUnansweredQuestions, we'll leverage the native browser fetch function to interact with our REST API. If you haven't already, let's open Visual Studio Code and carry out the following steps:

  1. Open QuestionsData.ts, find the getUnansweredQuestions function, and replace the implementation with the following content:
export const getUnansweredQuestions = async (): Promise<QuestionData[]> => {  let unansweredQuestions: QuestionData[] = []; // TODO - call api/questions/unanswered ...

Get ASP.NET Core 3 and React now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.