This commit is contained in:
Sean Morley
2024-07-17 10:35:42 -04:00
parent 824f5a6e2a
commit aa03c49979
2 changed files with 48 additions and 18 deletions

View File

@@ -6,6 +6,7 @@
import type { Adventure, Collection, User } from '$lib/types.js';
import { onMount } from 'svelte';
import { browser } from '$app/environment';
import { exportData } from '$lib';
export let data;
let user: User;
@@ -35,24 +36,7 @@
}
async function exportAdventures() {
let res = await fetch('/api/adventures/all');
let adventures = (await res.json()) as Adventure[];
res = await fetch('/api/collections/all');
let collections = (await res.json()) as Collection[];
res = await fetch('/api/visitedregion');
let visitedRegions = await res.json();
const data = {
adventures,
collections,
visitedRegions
};
const blob = new Blob([JSON.stringify(data)], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const url = await exportData();
const a = document.createElement('a');
a.href = url;