Use JSON arrays instead of plain text in API.

Suggested by Dianne Skoll.
This commit is contained in:
Juliusz Chroboczek
2024-05-03 18:54:22 +02:00
parent aa35408dba
commit a12331ee09
4 changed files with 42 additions and 61 deletions
+5 -6
View File
@@ -49,12 +49,11 @@ async function listObjects(url) {
let r = await fetch(url);
if(!r.ok)
throw httpError(r);
let strings = (await r.text()).split('\n');
if(strings[strings.length - 1] === '') {
strings.pop();
}
return strings;
}
let data = await r.json();
if(!(data instanceof Array))
throw new Error("Server didn't return array");
return data;
}
/**
* createObject makes a PUT request to url with JSON data.