Skip to content

Instantly share code, notes, and snippets.

@devuo
Last active February 11, 2019 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devuo/328433d716cbe6ffa3d019ee2723ed51 to your computer and use it in GitHub Desktop.
Save devuo/328433d716cbe6ffa3d019ee2723ed51 to your computer and use it in GitHub Desktop.
Table Data
interface Data {
clients: {
clientId: number,
errorConfigurations: {
userGroup: {
id: string
},
error: {
message: string
}
}[]
}[]
}
interface TableRow {
usedIn: string,
errorMessage: string,
clientId: number
}
const data: Data = {
clients: [
{
clientId: 12,
errorConfigurations: [
{
error: {
message: 'Oh noes'
},
userGroup: {
id: 'oh-no'
}
}
]
}
]
};
const table: TableRow[] = [];
for (const client of data.clients) {
for (const config of client.errorConfigurations) {
table.push({
errorMessage: config.error.message,
usedIn: config.userGroup.id,
clientId: client.clientId
})
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment