mirror of
https://github.com/graphql-hive/console
synced 2026-04-21 14:37:17 +00:00
27 lines
607 B
TypeScript
27 lines
607 B
TypeScript
import { getServiceHost } from './utils';
|
|
|
|
export interface Email {
|
|
to: string;
|
|
subject: string;
|
|
body: string;
|
|
}
|
|
|
|
export async function history(forEmail?: string): Promise<Email[]> {
|
|
const workflowsAddress = await getServiceHost('workflows', 3014);
|
|
|
|
const response = await fetch(`http://${workflowsAddress}/_history`, {
|
|
method: 'GET',
|
|
headers: {
|
|
accept: 'application/json',
|
|
'content-type': 'application/json',
|
|
},
|
|
});
|
|
|
|
const result: Email[] = await response.json();
|
|
|
|
if (!forEmail) {
|
|
return result;
|
|
}
|
|
|
|
return result.filter(result => result.to === forEmail);
|
|
}
|