fix(tools): better alert messaging (#54383)

Co-authored-by: Ben Zhang <bz2065@nyu.edu>
This commit is contained in:
benzoms
2024-04-15 02:00:25 -04:00
committed by GitHub
parent 5b311f9df1
commit 94e875bcc5
@@ -1,7 +1,20 @@
export const handleRequest = (makeRequest: () => Promise<Response>) => () => {
makeRequest()
.then(res => res.json() as Promise<{ stdout: string; stderr: string }>)
.then(data => alert(JSON.stringify(data)))
.then(
res =>
res.json() as Promise<{
stdout?: string;
stderr?: string;
message?: string;
}>
)
.then(data => {
if (data.message) {
alert(data.message);
} else {
alert(JSON.stringify(data));
}
})
.catch(err => console.error(err));
};