I'm creating a table using react-table and Typescript. Now I'm having some difficulty in accessing the data I get returned from my API. I'm just using Google Books API. Now I've created a table component, which receives some data which is an array with objects. Now these objects contain nested data which I have defined in a Books interface, in which I only include the data I need from the API response.
Below is my Book interface:
export interface Book {
id: number;
isbn: {
volumeInfo: {
industryIdentifiers: {
type: string;
identifier: string;
}[];
};
};
title: {
volumeInfo: {
title: string;
};
};
authors: {
volumeInfo: {
authors: string[];
};
};
publishedDate: {
volumeInfo: {
publishedDate: string[];
};
};
}
I've created an array where I've defined my columns using documentation from react-table:
import { Book } from "./home.types";
const columnHelper = createColumnHelper<Book>();
const columns = [
columnHelper.accessor("id", {
header: () => "ID",
cell: (info) => info.getValue(),
}),
columnHelper.accessor("isbn", {
header: () => "ISBN",
cell: (info) => info.getValue(),
}),
columnHelper.accessor("title", {
header: () => "Title",
cell: (info) => info.getValue(),
}),
columnHelper.accessor("authors", {
header: () => "Authors",
cell: (info) => info.getValue(),
}),
columnHelper.accessor("publishedDate", {
header: () => "Date of publication",
cell: (info) => info.getValue(),
}),
];
The issue I'm experiencing is that the data is being loaded in the table, but all other data isn't, and I don't really see why. I'm pointing to the locations of the data in the response I'm feeding my table.
I think I'm just not clearly seeing it, can anyone point me in the right direction?