mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-13 19:00:41 -04:00
23 lines
523 B
TypeScript
23 lines
523 B
TypeScript
export const handleRequest = (makeRequest: () => Promise<Response>) => () => {
|
|
makeRequest()
|
|
.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));
|
|
};
|
|
|
|
export const API_LOCATION = import.meta.env
|
|
.CHALLENGE_EDITOR_API_LOCATION as string;
|