parser.js 793 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { element } from "./element.js";
  2. import { submission } from "./submission.js";
  3. class parser {
  4. #source_url;
  5. #database;
  6. constructor(source_url) {
  7. if (typeof(source_url) !== "string") {
  8. throw "Source URL must be an string.";
  9. }
  10. this.#source = source;
  11. this.#database = undefined;
  12. }
  13. async load() {
  14. const result = await fetch(this.#source);
  15. if (!result.ok) {
  16. throw "Can not load database from server.";
  17. }
  18. if (result.status !== 200) {
  19. throw "Can not load database from server. Result not 200.";
  20. }
  21. const database = await result.json();
  22. this.#fetch_result(database);
  23. }
  24. #fetch_result(database) {
  25. }
  26. }
  27. export { parser };