mirror of
https://git.srhtnin.garden/sarah/srhtnin.github.io.git
synced 2026-10-13 18:38:11 +02:00
51 lines
924 B
JavaScript
51 lines
924 B
JavaScript
let MutationSets = {};
|
|
|
|
|
|
async function FetchMutationsFromApi() {
|
|
const Response =
|
|
await fetch(
|
|
ApiUrl + "/Mutations.php",
|
|
{
|
|
method: "GET",
|
|
|
|
headers: {
|
|
"Accept":
|
|
"application/json"
|
|
},
|
|
|
|
cache: "no-store"
|
|
}
|
|
);
|
|
|
|
|
|
if (!Response.ok) {
|
|
throw new Error(
|
|
"Mutations API returned HTTP " +
|
|
Response.status
|
|
);
|
|
}
|
|
|
|
|
|
const Result =
|
|
await Response.json();
|
|
|
|
|
|
if (
|
|
!Result.Success ||
|
|
Result.Mutations === null ||
|
|
typeof Result.Mutations !==
|
|
"object" ||
|
|
Array.isArray(
|
|
Result.Mutations
|
|
)
|
|
) {
|
|
throw new Error(
|
|
Result.Error ??
|
|
"Mutations API returned invalid data."
|
|
);
|
|
}
|
|
|
|
|
|
return Result.Mutations;
|
|
}
|