<script>
let input="Pompidou Georges";
let results;
$: input && fetch(`https://deces.matchid.io/deces/api/v1/search?q=${input}'`)
.then(response => response.json())
.then( data => results = data.response && data.response.persons)
</script>
<h1>Recherche décès</h1>
<form class="content">
<input name="search" type="text" bind:value={input} />
</form>
{#if input && results && results.length}
{#each results as result}
<small>Nom: {result.name.last}, Prénoms: {result.name.first[0]}, décès: {result.death.date.replace(/(....)(..)(..)/,'$3/$2/$1')} </small> <br>
{/each}
{/if}