mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(tools): better alert messaging (#54383)
Co-authored-by: Ben Zhang <bz2065@nyu.edu>
This commit is contained in:
@@ -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));
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user