I am receiving a JSON response from Firebase with the following format:
{ "-KD8Evk7TULU6t6zxMHl": { "createdAt": 1458296568840, "isActive": true, "title": "...add a title", "updatedAt": 1458296568840 } }
Question Part One: How should I define my Typescript Interface for this specific JSON structure? Should it look something like the example provided below?
export interface Hero {
[id: string]: {
createdAt: number;
isActive: boolean;
title: string;
updatedAt: number;
}
}
Question Part Two: What is the recommended way to access the title or id of a hero using the Typescript interface mentioned above? For instance, if I want to showcase the hero's id and title on a webpage.
<html>
...omitted code for brevity. Displaying hero id and title below.
<h1> {{ hero.id }} </h1>
<h1> {{ hero.title }} </h1>
</html>