Does it work with a promise? I have undefined.
davy-blavette opened this issue · 2 comments
davy-blavette commented
Hi,
Maybe it doesn't work on a promise ?
<script>
import { onMount } from "svelte";
import {baseUrl} from "../data";
import JSONTree from 'svelte-json-tree';
let jsonTrainers;
onMount(async () => {
let res = await fetch(baseUrl);
const trainer = res.json();
trainer.then(function(result) {
jsonTrainers = result[0].kolb.reponse;
console.log(jsonTrainers);
});
});
</script>
<JSONTree {jsonTrainers} /> // <---- undefined
tanhauhau commented
you need to pass the value in through the props named value
<JSONTree value={jsonTrainers} />
davy-blavette commented
Thanks, perfect 👍